-
Notifications
You must be signed in to change notification settings - Fork 0
/
mrimchatsession.cpp
99 lines (75 loc) · 3.02 KB
/
mrimchatsession.cpp
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
90
91
92
93
94
95
96
97
98
99
#include <kcomponentdata.h>
#include <kactionmenu.h>
#include <klocale.h>
#include <kmenu.h>
#include <kactioncollection.h>
#include <kopete/kopetechatsessionmanager.h>
#include <kopete/kopeteaccount.h>
#include <kopete/ui/kopetecontactaction.h>
#include "ui/createconferencedialog.h"
#include "mra/mraconferencesettings.h"
#include "mrimcontact.h"
#include "mrimaccount.h"
#include "mrimprotocol.h"
#include "debug.h"
#include "mrimchatsession.h"
class MrimChatSession::Private {
public:
MrimContact *contact;
KAction *editConferenceAction;
MRAConferenceSettings conferenceSettings;
};
MrimChatSession::MrimChatSession(const Kopete::Contact *user,
MrimContact *contact,
Kopete::ContactPtrList others,
MrimProtocol *protocol,
Form form = Small ) :
Kopete::ChatSession(user, others, protocol, form),
d(new Private)
{
Kopete::ChatSessionManager::self()->registerChatSession( this );
setComponentData( protocol->componentData() );
d->contact = contact;
setMayInvite( contact->isChatContact() );
d->editConferenceAction = new KAction(KIcon("system-users"), i18n ("&Edit conference"), this);
connect(d->editConferenceAction, SIGNAL(triggered()), this, SLOT(slotEditConference()));
actionCollection()->addAction("mrimEditConference", d->editConferenceAction);
setXMLFile( "kopetemrimchatui.rc" );
}
MrimChatSession::~MrimChatSession() {
delete d;
}
void MrimChatSession::slotEditConference() {
CreateConferenceDialog dialog(dynamic_cast<MrimAccount*>(account()));
dialog.setSettings(d->conferenceSettings);
if ( dialog.exec() == QDialog::Accepted ) {
//
MRAConferenceSettings newSettings = dialog.getSettings();
// current contact is not present in the "list of available contacts"
newSettings.addContact( account()->myself()->contactId() );
if (newSettings != d->conferenceSettings) {
MRAConferenceSettings::difference
diff = MRAConferenceSettings::compare(d->conferenceSettings, newSettings);
foreach (const QString &contactId, diff.deletedItems) {
mrimWarning() << "deleted" << contactId;
d->contact->removeContactFromConference(contactId);
}
foreach (const QString &contactId, diff.newItems) {
mrimWarning() << "new" << contactId;
d->contact->inviteContactToConference(contactId);
}
}
}
}
void MrimChatSession::inviteContact(const QString &contactId) {
d->contact->inviteContactToConference(contactId);
}
void MrimChatSession::slotChatSettingsReceived(const MRAConferenceSettings &settings) {
foreach(const QString &contact, settings.contactList()) {
if ( account()->contacts().value(contact) ) {
addContact( account()->contacts().value(contact) );
}
}
setDisplayName(settings.title());
d->conferenceSettings = settings;
}