make webinterface translatable. there are around 20 short strings, all with context...
[kdenetwork.git] / kopete / protocols / sms / smscontact.cpp
blobd9df636e6f0ecae49fec709f1697796464f18019
1 /* *************************************************************************
2 * copyright: (C) 2003 Richard Lärkäng <nouseforaname@home.se> *
3 * copyright: (C) 2003 Gav Wood <gav@kde.org> *
4 *************************************************************************
5 */
7 /* *************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 *************************************************************************
17 #undef KDE_NO_COMPAT
18 #include <kconfigbase.h>
19 #include <kaction.h>
20 #include <kdebug.h>
21 #include <klocale.h>
22 #include <kmessagebox.h>
23 #include <kactioncollection.h>
25 #include "kopetechatsessionmanager.h"
26 #include "kopeteaccount.h"
27 #include "kopeteuiglobal.h"
29 #include "smscontact.h"
30 #include "smsprotocol.h"
31 #include "smsservice.h"
32 #include "smsaccount.h"
33 #include "smsuserpreferences.h"
35 SMSContact::SMSContact( Kopete::Account* _account, const QString &phoneNumber,
36 const QString &displayName, Kopete::MetaContact *parent )
37 : Kopete::Contact( _account, phoneNumber, parent ), m_phoneNumber( phoneNumber )
39 // kWarning( 14160 ) << " this = " << this << ", phone = " << phoneNumber;
40 setNickName( displayName );
42 m_msgManager = 0L;
43 m_actionPrefs = 0L;
45 if( account()->isConnected() )
46 setOnlineStatus( SMSProtocol::protocol()->SMSOnline );
49 void SMSContact::slotSendingSuccess(const Kopete::Message &msg)
51 manager(Kopete::Contact::CanCreate)->messageSucceeded();
52 manager(Kopete::Contact::CanCreate)->appendMessage((Kopete::Message &)msg);
55 void SMSContact::slotSendingFailure(const Kopete::Message &/*msg*/, const QString &error)
57 KMessageBox::detailedError(Kopete::UI::Global::mainWidget(), i18n("Something went wrong while sending the message."), error,
58 i18n("Could Not Send Message"));
59 // manager()->messageFailed();
60 // TODO: swap for failed as above. show it anyway for now to allow closing of window.
61 manager(Kopete::Contact::CanCreate)->messageSucceeded();
64 void SMSContact::serialize( QMap<QString, QString> &serializedData,
65 QMap<QString, QString> & /* addressBookData */ )
67 // Contact id and display name are already set for us
68 if (m_phoneNumber != contactId())
69 serializedData[ "contactId" ] = m_phoneNumber;
72 Kopete::ChatSession* SMSContact::manager( Kopete::Contact::CanCreateFlags canCreate )
74 if ( m_msgManager || canCreate != Kopete::Contact::CanCreate )
76 return m_msgManager;
78 else
80 QList<Kopete::Contact*> contacts;
81 contacts.append(this);
82 m_msgManager = Kopete::ChatSessionManager::self()->create(account()->myself(), contacts, protocol());
83 connect(m_msgManager, SIGNAL(messageSent(Kopete::Message&, Kopete::ChatSession*)),
84 account(), SLOT(slotSendMessage(Kopete::Message&)));
85 connect(m_msgManager, SIGNAL(destroyed()), this, SLOT(slotChatSessionDestroyed()));
86 return m_msgManager;
90 void SMSContact::slotChatSessionDestroyed()
92 m_msgManager = 0L;
96 void SMSContact::slotUserInfo()
100 void SMSContact::deleteContact()
102 deleteLater();
105 const QString SMSContact::qualifiedNumber()
107 QString number = m_phoneNumber;
108 dynamic_cast<SMSAccount *>(account())->translateNumber(number);
109 return number;
112 const QString &SMSContact::phoneNumber()
114 return m_phoneNumber;
117 void SMSContact::setPhoneNumber( const QString phoneNumber )
119 deleteLater();
120 new SMSContact(account(), phoneNumber, nickName(), metaContact());
123 KActionCollection* SMSContact::customContextMenuActions(QWidget *parent)
125 KActionCollection *m_actionCollection = new KActionCollection(parent);
127 if( !m_actionPrefs )
129 m_actionPrefs = new KAction(i18n("&Contact Settings"),
130 m_actionCollection );
132 // dynamic_cast<QObject*>(this),
133 // SLOT(userPrefs()),
134 // dynamic_cast<QObject*>(this),
135 // "userPrefs");
136 QObject::connect(m_actionPrefs,
137 SIGNAL(triggered(bool)),
138 dynamic_cast<QObject*>(this),
139 SLOT(userPrefs()));
142 m_actionCollection->addAction("userPrefs", m_actionPrefs);
144 return m_actionCollection;
147 void SMSContact::userPrefs()
149 SMSUserPreferences* p = new SMSUserPreferences( this );
150 p->show();
153 #include "smscontact.moc"
155 // vim: set noet ts=4 sts=4 sw=4: