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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
/* *************************************************************************
* copyright: (C) 2003 Richard Lärkäng <nouseforaname@home.se> *
* copyright: (C) 2003 Gav Wood <gav@kde.org> *
*************************************************************************
*/
/* *************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
*************************************************************************
*/
#undef KDE_NO_COMPAT
#include <tdeconfigbase.h>
#include <tdeaction.h>
#include <kdebug.h>
#include <klocale.h>
#include <kmessagebox.h>
#include "kopetechatsessionmanager.h"
#include "kopeteaccount.h"
#include "kopeteuiglobal.h"
#include "smscontact.h"
#include "smsprotocol.h"
#include "smsservice.h"
#include "smsaccount.h"
#include "smsuserpreferences.h"
SMSContact::SMSContact( Kopete::Account* _account, const TQString &phoneNumber,
const TQString &displayName, Kopete::MetaContact *parent )
: Kopete::Contact( _account, phoneNumber, parent ), m_phoneNumber( phoneNumber )
{
// kdWarning( 14160 ) << k_funcinfo << " this = " << this << ", phone = " << phoneNumber << endl;
setNickName( displayName );
m_msgManager = 0L;
m_actionPrefs = 0L;
if( account()->isConnected() )
setOnlineStatus( SMSProtocol::protocol()->SMSOnline );
}
void SMSContact::slotSendingSuccess(const Kopete::Message &msg)
{
manager(Kopete::Contact::CanCreate)->messageSucceeded();
manager(Kopete::Contact::CanCreate)->appendMessage((Kopete::Message &)msg);
}
void SMSContact::slotSendingFailure(const Kopete::Message &/*msg*/, const TQString &error)
{
KMessageBox::detailedError(Kopete::UI::Global::mainWidget(), i18n("Something went wrong when sending message."), error,
i18n("Could Not Send Message"));
// manager()->messageFailed();
// TODO: swap for failed as above. show it anyway for now to allow closing of window.
manager(Kopete::Contact::CanCreate)->messageSucceeded();
}
void SMSContact::serialize( TQMap<TQString, TQString> &serializedData,
TQMap<TQString, TQString> & /* addressBookData */ )
{
// Contact id and display name are already set for us
if (m_phoneNumber != contactId())
serializedData[ "contactId" ] = m_phoneNumber;
}
Kopete::ChatSession* SMSContact::manager( Kopete::Contact::CanCreateFlags canCreate )
{
if ( m_msgManager || canCreate != Kopete::Contact::CanCreate )
{
return m_msgManager;
}
else
{
TQPtrList<Kopete::Contact> contacts;
contacts.append(this);
m_msgManager = Kopete::ChatSessionManager::self()->create(account()->myself(), contacts, protocol());
connect(m_msgManager, TQT_SIGNAL(messageSent(Kopete::Message&, Kopete::ChatSession*)),
account(), TQT_SLOT(slotSendMessage(Kopete::Message&)));
connect(m_msgManager, TQT_SIGNAL(destroyed()), this, TQT_SLOT(slotChatSessionDestroyed()));
return m_msgManager;
}
}
void SMSContact::slotChatSessionDestroyed()
{
m_msgManager = 0L;
}
void SMSContact::slotUserInfo()
{
}
void SMSContact::deleteContact()
{
deleteLater();
}
const TQString SMSContact::qualifiedNumber()
{
TQString number = m_phoneNumber;
dynamic_cast<SMSAccount *>(account())->translateNumber(number);
return number;
}
const TQString &SMSContact::phoneNumber()
{
return m_phoneNumber;
}
void SMSContact::setPhoneNumber( const TQString phoneNumber )
{
deleteLater();
new SMSContact(account(), phoneNumber, nickName(), metaContact());
}
TQPtrList<TDEAction>* SMSContact::customContextMenuActions()
{
TQPtrList<TDEAction> *m_actionCollection = new TQPtrList<TDEAction>();
if( !m_actionPrefs )
m_actionPrefs = new TDEAction(i18n("&Contact Settings"), 0, this, TQT_SLOT(userPrefs()), this, "userPrefs");
m_actionCollection->append( m_actionPrefs );
return m_actionCollection;
}
void SMSContact::userPrefs()
{
SMSUserPreferences* p = new SMSUserPreferences( this );
p->show();
}
#include "smscontact.moc"
// vim: set noet ts=4 sts=4 sw=4:
|