summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/groupwise/libgroupwise/tasks/createcontacttask.h
blob: f63a19afe01cd7c6c87df2c8d7b35cdc6610b980 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
    Kopete Groupwise Protocol
    createcontacttask.cpp - high level task responsible for creating both a contact and any folders it belongs to locally, 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.      *
    *                                                                       *
    *************************************************************************
*/

#ifndef CREATECONTACTTASK_H
#define CREATECONTACTTASK_H

#include <tqvaluelist.h>

#include "gwerror.h"

#include "task.h"

using namespace GroupWise;

/**
	Creates a contact on the server, as well as any folders that do not exist on the server, and add the contact to those folders.
	This is a meta-task to suit Kopete.  If you maintain your own copy of the server side contact list and follow the server's 
	contact semantics (contact instances rather than contacts in the contact list), you can just use CreateContactInstanceTask.
	This task causes the @ref Client to emit folderReceived() and contactReceived() as the task proceeds.  Kopete processes these 
	signals as usual, because it created the contact optimistically, before invoking this task.

	The finished() signal indicates the whole procedure has completed and the sender can be queried for success as usual
@author SUSE AG
*/
class CreateContactTask : public Task
{
Q_OBJECT
  TQ_OBJECT
public:
	CreateContactTask(Task* parent);
	~CreateContactTask();
	/**
	 * Get the userId of the contact just created
	 */
	TQString userId();
	/**
	 * Get the DN of the contact just created
	 */
	TQString dn();
	TQString displayName();

	/** 
	 * Sets up the task.
	 * @param userId the user Id of the contact to create
	 * @param displayName the display name we should give to this contact
	 * @param firstSeqNo Used to create the folders - the first unused folder sequence number we know of
	 * @param folders A list of folders that the contact should belong to - any folders that do not exist on the server should have a objectId of 0, and will be created
	 * @param topLevel is the folder also in the top level folder?
	 */
	void contactFromUserId( const TQString & userId, const TQString & displayName, const int firstSeqNo, const TQValueList< FolderItem > folders, bool topLevel );
	//void contactFromDN( const TQString & dn, const TQString & displayName, const int parentFolder );
	/** 
	 * This task doesn't do any I/O itself, so this take prints an error and returns false;
	 */
	bool take( Transfer * );
	/** 
	 * Starts off the whole process
	 */
	void onGo();
protected slots:
	void slotContactAdded( const ContactItem & );
	void slotCheckContactInstanceCreated();
private:
	int m_firstSequenceNumber;
	TQString m_userId;
	TQString m_dn;
	TQString m_displayName;
	TQValueList< FolderItem > m_folders;
	bool m_topLevel;
};

#endif