summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/groupwise/libgroupwise/tasks/updatecontacttask.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kopete/protocols/groupwise/libgroupwise/tasks/updatecontacttask.cpp')
-rw-r--r--kopete/protocols/groupwise/libgroupwise/tasks/updatecontacttask.cpp76
1 files changed, 76 insertions, 0 deletions
diff --git a/kopete/protocols/groupwise/libgroupwise/tasks/updatecontacttask.cpp b/kopete/protocols/groupwise/libgroupwise/tasks/updatecontacttask.cpp
new file mode 100644
index 00000000..d8c1a68a
--- /dev/null
+++ b/kopete/protocols/groupwise/libgroupwise/tasks/updatecontacttask.cpp
@@ -0,0 +1,76 @@
+/*
+ Kopete Groupwise Protocol
+ updatecontacttask.cpp - rename a contact on the server
+
+ Copyright (c) 2004 SUSE Linux AG http://www.suse.com
+
+ Based on Iris, Copyright (C) 2003 Justin Karneges
+
+ Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * This library is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2 of the License, or (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#include "gwfield.h"
+
+#include "updatecontacttask.h"
+
+using namespace GroupWise;
+
+UpdateContactTask::UpdateContactTask(Task* parent): UpdateItemTask(parent)
+{
+}
+
+
+UpdateContactTask::~UpdateContactTask()
+{
+}
+
+QString UpdateContactTask::displayName()
+{
+ return m_name;
+}
+
+void UpdateContactTask::renameContact( const QString & newName, const QValueList<ContactItem> & contactInstances )
+{
+ m_name = newName;
+ // build a list of delete, add fields that removes each instance on the server and then readds it with the new name
+ Field::FieldList lst;
+ const QValueList<ContactItem>::ConstIterator end = contactInstances.end();
+ for( QValueList<ContactItem>::ConstIterator it = contactInstances.begin(); it != end; ++it )
+ {
+ Field::FieldList contactFields;
+ contactFields.append( new Field::SingleField( NM_A_SZ_OBJECT_ID, 0, NMFIELD_TYPE_UTF8, (*it).id ) );
+ contactFields.append( new Field::SingleField( NM_A_SZ_PARENT_ID, 0, NMFIELD_TYPE_UTF8, (*it).parentId ) );
+ contactFields.append( new Field::SingleField( NM_A_SZ_SEQUENCE_NUMBER, 0, NMFIELD_TYPE_UTF8, (*it).sequence ) );
+ if ( !(*it).dn.isNull() )
+ contactFields.append( new Field::SingleField( NM_A_SZ_DN, 0, NMFIELD_TYPE_UTF8, (*it).dn ) );
+ if ( !(*it).displayName.isNull() )
+ contactFields.append( new Field::SingleField( NM_A_SZ_DISPLAY_NAME, 0, NMFIELD_TYPE_UTF8, (*it).displayName ) );
+ lst.append(
+ new Field::MultiField( NM_A_FA_CONTACT, NMFIELD_METHOD_DELETE, 0, NMFIELD_TYPE_ARRAY, contactFields ) );
+ }
+ for( QValueList<ContactItem>::ConstIterator it = contactInstances.begin(); it != end; ++it )
+ {
+ Field::FieldList contactFields;
+ contactFields.append( new Field::SingleField( NM_A_SZ_OBJECT_ID, 0, NMFIELD_TYPE_UTF8, (*it).id ) );
+ contactFields.append( new Field::SingleField( NM_A_SZ_PARENT_ID, 0, NMFIELD_TYPE_UTF8, (*it).parentId ) );
+ contactFields.append( new Field::SingleField( NM_A_SZ_SEQUENCE_NUMBER, 0, NMFIELD_TYPE_UTF8, (*it).sequence ) );
+ if ( !(*it).dn.isNull() )
+ contactFields.append( new Field::SingleField( NM_A_SZ_DN, 0, NMFIELD_TYPE_UTF8, (*it).dn ) );
+ contactFields.append( new Field::SingleField( NM_A_SZ_DISPLAY_NAME, 0, NMFIELD_TYPE_UTF8, newName ) );
+ lst.append(
+ new Field::MultiField( NM_A_FA_CONTACT, NMFIELD_METHOD_ADD, 0, NMFIELD_TYPE_ARRAY, contactFields ) );
+ }
+ //lst.dump( true );
+ UpdateItemTask::item( lst );
+}
+
+#include "updatecontacttask.moc"