diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | bcb704366cb5e333a626c18c308c7e0448a8e69f (patch) | |
tree | f0d6ab7d78ecdd9207cf46536376b44b91a1ca71 /kopete/protocols/meanwhile | |
download | tdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.tar.gz tdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kopete/protocols/meanwhile')
33 files changed, 3267 insertions, 0 deletions
diff --git a/kopete/protocols/meanwhile/Makefile.am b/kopete/protocols/meanwhile/Makefile.am new file mode 100644 index 00000000..e161fac3 --- /dev/null +++ b/kopete/protocols/meanwhile/Makefile.am @@ -0,0 +1,37 @@ +METASOURCES = AUTO +SUBDIRS = ui icons + +AM_CPPFLAGS = $(KOPETE_INCLUDES) \ + -I$(srcdir)/ui \ + -I./ui \ + $(all_includes) \ + $(MEANWHILE_CFLAGS) + +noinst_HEADERS = \ + meanwhileprotocol.h \ + meanwhileaddcontactpage.h \ + meanwhileeditaccountwidget.h \ + meanwhileaccount.h \ + meanwhilecontact.h \ + meanwhilesession.h \ + meanwhileplugin.h + +kde_module_LTLIBRARIES = kopete_meanwhile.la + +kopete_meanwhile_la_SOURCES = \ + meanwhileprotocol.cpp \ + meanwhileaddcontactpage.cpp \ + meanwhileeditaccountwidget.cpp \ + meanwhileaccount.cpp \ + meanwhilecontact.cpp \ + meanwhilesession.cpp \ + meanwhileplugin.cpp + +kopete_meanwhile_la_LDFLAGS = -no-undefined -module \ + $(KDE_PLUGIN) $(all_libraries) + +kopete_meanwhile_la_LIBADD = $(top_builddir)/kopete/libkopete/libkopete.la \ + ui/libkopetemeanwhileui.la $(MEANWHILE_LIBS) + +service_DATA = kopete_meanwhile.desktop +servicedir= $(kde_servicesdir) diff --git a/kopete/protocols/meanwhile/README b/kopete/protocols/meanwhile/README new file mode 100644 index 00000000..5c77dbf6 --- /dev/null +++ b/kopete/protocols/meanwhile/README @@ -0,0 +1,53 @@ +This is a kopete plugin for meanwhile using the libmeanwhile library. + +To INSTALL +========== + +1. install libmeanwhile +2. install kopete with the meanwhile plugin. + +installing libmeanwhile +======================= +from http://meanwhile.sf.net - use version 0.3 +Refer to INSTALL in the meanwhile code. Run configure without specifying the --with_gaim_src + # autogen.sh + # ./configure --prefix=/usr + # make + # su -c make install + +installing kopete with meanwhile plugin +======================================= +1. Get kopete src from kopete.kde.org (latest cvs) +2. move this directory to $KOPETE_SRC/kopete/protocols/meanwhile, +3. patch the configure script in $KOPETE_SRC to pickup meanwhile + in $KOPETE_SRC + # patch -P0 < kopete/protocols/meanwhile/configure.patch +4. patch Makefile.am in protocols with protocols-makefile.patch + in $KOPETE_SRC + # patch -P0 < kopete/protocols/meanwhile/protocols-makefile.patch +5. run automake to process this Makefile.am + in $KOPETE_SRC + # automake kopete/protocols/Makefile +6. libmeanwhile uses glib and kopete's makefile have no references to glib, so + edit $KOPETE_SRC/kopete/protocols/meanwhile/Makefile.am and verify that + GLIB_INCLUDES points to the right places. These variables are currently + set for Fedora-core-1. If you have to modify the variable, rebuild the + makefile. + in $KOPETE_SRC + # automake kopete/protocols/meanwhile/Makefile +7. follow the steps defined in kopete INSTALL: + on fedora/redhat this could be (from $KOPETE_SRC) + # ./configure --prefix=/usr/ + # make + # make install +7.1 if you want to install only meanwhile on an existing copy of kopete, + after the make, try make install in + $KOPETE_SRC/kopete/protocols/meanwhile + +8. enjoy*. + +* Hopefully i have fixed this, but when you try to add accounts and you +donot find meanwhile listed, copy kopete/protocols/meanwhile/kopete_meanwhile.desktop +to $KDE_DIR/share/services (/usr/share/services on fedora). +* If you find the icons for meanwhile missing, overwrite Makefile in + kopete/protocols/meanwhile/icons with Makefile.siva diff --git a/kopete/protocols/meanwhile/icons/Makefile.am b/kopete/protocols/meanwhile/icons/Makefile.am new file mode 100644 index 00000000..9143c6b4 --- /dev/null +++ b/kopete/protocols/meanwhile/icons/Makefile.am @@ -0,0 +1,2 @@ +kopeteicondir = $(kde_datadir)/kopete/icons +kopeteicon_ICON = AUTO diff --git a/kopete/protocols/meanwhile/icons/cr128-app-meanwhile_protocol.png b/kopete/protocols/meanwhile/icons/cr128-app-meanwhile_protocol.png Binary files differnew file mode 100644 index 00000000..93289326 --- /dev/null +++ b/kopete/protocols/meanwhile/icons/cr128-app-meanwhile_protocol.png diff --git a/kopete/protocols/meanwhile/icons/cr16-action-meanwhile_away.png b/kopete/protocols/meanwhile/icons/cr16-action-meanwhile_away.png Binary files differnew file mode 100644 index 00000000..9dc152db --- /dev/null +++ b/kopete/protocols/meanwhile/icons/cr16-action-meanwhile_away.png diff --git a/kopete/protocols/meanwhile/icons/cr16-action-meanwhile_dnd.png b/kopete/protocols/meanwhile/icons/cr16-action-meanwhile_dnd.png Binary files differnew file mode 100644 index 00000000..df361d8d --- /dev/null +++ b/kopete/protocols/meanwhile/icons/cr16-action-meanwhile_dnd.png diff --git a/kopete/protocols/meanwhile/icons/cr16-action-meanwhile_idle.png b/kopete/protocols/meanwhile/icons/cr16-action-meanwhile_idle.png Binary files differnew file mode 100644 index 00000000..4b97a931 --- /dev/null +++ b/kopete/protocols/meanwhile/icons/cr16-action-meanwhile_idle.png diff --git a/kopete/protocols/meanwhile/icons/cr16-action-meanwhile_unknown.png b/kopete/protocols/meanwhile/icons/cr16-action-meanwhile_unknown.png Binary files differnew file mode 100644 index 00000000..673c937a --- /dev/null +++ b/kopete/protocols/meanwhile/icons/cr16-action-meanwhile_unknown.png diff --git a/kopete/protocols/meanwhile/icons/cr16-app-meanwhile_protocol.png b/kopete/protocols/meanwhile/icons/cr16-app-meanwhile_protocol.png Binary files differnew file mode 100644 index 00000000..69767ef3 --- /dev/null +++ b/kopete/protocols/meanwhile/icons/cr16-app-meanwhile_protocol.png diff --git a/kopete/protocols/meanwhile/icons/cr22-app-meanwhile_protocol.png b/kopete/protocols/meanwhile/icons/cr22-app-meanwhile_protocol.png Binary files differnew file mode 100644 index 00000000..87aec661 --- /dev/null +++ b/kopete/protocols/meanwhile/icons/cr22-app-meanwhile_protocol.png diff --git a/kopete/protocols/meanwhile/icons/cr32-app-meanwhile_protocol.png b/kopete/protocols/meanwhile/icons/cr32-app-meanwhile_protocol.png Binary files differnew file mode 100644 index 00000000..72cf82ab --- /dev/null +++ b/kopete/protocols/meanwhile/icons/cr32-app-meanwhile_protocol.png diff --git a/kopete/protocols/meanwhile/icons/cr48-app-meanwhile_protocol.png b/kopete/protocols/meanwhile/icons/cr48-app-meanwhile_protocol.png Binary files differnew file mode 100644 index 00000000..49c08f76 --- /dev/null +++ b/kopete/protocols/meanwhile/icons/cr48-app-meanwhile_protocol.png diff --git a/kopete/protocols/meanwhile/icons/cr64-app-meanwhile_protocol.png b/kopete/protocols/meanwhile/icons/cr64-app-meanwhile_protocol.png Binary files differnew file mode 100644 index 00000000..f4b008e7 --- /dev/null +++ b/kopete/protocols/meanwhile/icons/cr64-app-meanwhile_protocol.png diff --git a/kopete/protocols/meanwhile/icons/crsc-app-meanwhile_protocol.svgz b/kopete/protocols/meanwhile/icons/crsc-app-meanwhile_protocol.svgz Binary files differnew file mode 100644 index 00000000..55e6ef45 --- /dev/null +++ b/kopete/protocols/meanwhile/icons/crsc-app-meanwhile_protocol.svgz diff --git a/kopete/protocols/meanwhile/kopete_meanwhile.desktop b/kopete/protocols/meanwhile/kopete_meanwhile.desktop new file mode 100644 index 00000000..80aa6383 --- /dev/null +++ b/kopete/protocols/meanwhile/kopete_meanwhile.desktop @@ -0,0 +1,58 @@ +[Desktop Entry] +Type=Service +X-Kopete-Version=1000900 +Icon=meanwhile_protocol +ServiceTypes=Kopete/Protocol +X-KDE-Library=kopete_meanwhile +X-Kopete-Messaging-Protocol=messaging/meanwhile +X-KDE-PluginInfo-Author=Jeremy Kerr +X-KDE-PluginInfo-Name=kopete_meanwhile +X-KDE-PluginInfo-Version=0.0.1 +X-KDE-PluginInfo-Website=http://kopete.kde.org +X-KDE-PluginInfo-Category=Protocols +X-KDE-PluginInfo-Depends= +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=false +Name=Meanwhile +Name[is]=Á meðan +Name[mk]=Во меѓувреме +Name[nb]=Imens +Name[ne]=उक्त अवधि +Name[sk]=Medzitým +Name[ta]=இடைப்பட்ட பொழுதில் +Comment=Meanwhile (Lotus Sametime) Protocol +Comment[bg]=Протокол с Meanwhile (Lotus Sametime) +Comment[ca]=Protocol Meanwhile (Lotus Sametime) +Comment[cs]=Meanwhile (Lotus Sametime) protokol +Comment[da]=Meanwhile-protokol (Lotus Sametime) +Comment[de]=Meanwhile-Protokoll (Lotus Sametime) +Comment[el]=Πρωτόκολλο Meanwhile (Lotus Sametime) +Comment[es]=Protocolo Meanwhile (Lotus Sametime) +Comment[et]=Meanwhile (Lotus Sametime) protokoll +Comment[fa]=قرارداد Meanwhile (گاهی لوتوس) +Comment[fr]=Protocole Meanwhile (Lotus Sametime) +Comment[he]=פרוטוקול Meanwhile +Comment[hu]=Protokoll a Meanwhile (Lotus Sametime) használatához +Comment[is]="Meanwhile" (Lotus Sametimr) samskipturegla +Comment[it]=Protocollo Meanwhile (Lotus Sametime) +Comment[ja]=Meanwhile (Lotus Sametime) プロトコル +Comment[km]=ពីធីការ Meanwhile (Lotus Sametime) +Comment[lt]=Meanwhile (Lotus Sametime) protokolas +Comment[nb]=Programtillegg for Meanwhile-protokoll (Lotus Sametime) +Comment[nds]=Meanwhile-Protokoll (Lotus Sametime) +Comment[ne]=उक्त समयको (उही समयको लोटस) प्रोटोकल +Comment[nl]=Procotol voor Meanwhile (Lotus Sametime) +Comment[pl]=Protokół Meanwhile (Lotus Sametime) +Comment[pt]=Protocolo Meanwhile (Lotus Sametime) +Comment[pt_BR]=Protocolo Meanwhile (Lotus Sametime) +Comment[ru]=Протокол Meanwhile (Lotus Sametime) +Comment[sk]=Meanwhile (Lotus Sametime) Protokol +Comment[sl]=Protokol Meanwhile (Lotus Sametime) +Comment[sr]=Протокол Meanwhile (Lotus Sametime) +Comment[sr@Latn]=Protokol Meanwhile (Lotus Sametime) +Comment[sv]=Meanwhile-protokoll (Lotus Sametime) +Comment[tr]=Meanwhile Protokolü +Comment[uk]=Протокол Meanwhile (Lotus Sametime) +Comment[zh_CN]=Meanwhile (Lotus Sametime) 协议 +Comment[zh_TW]=Meanwhile (Lotus Sametime)協定外掛程式 diff --git a/kopete/protocols/meanwhile/meanwhileaccount.cpp b/kopete/protocols/meanwhile/meanwhileaccount.cpp new file mode 100644 index 00000000..c130475b --- /dev/null +++ b/kopete/protocols/meanwhile/meanwhileaccount.cpp @@ -0,0 +1,274 @@ +/* + meanwhileaccount.cpp - a meanwhile account + + Copyright (c) 2003-2004 by Sivaram Gottimukkala <[email protected]> + Copyright (c) 2005 by Jeremy Kerr <[email protected]> + + Kopete (c) 2002-2004 by the Kopete developers <[email protected]> + + ************************************************************************* + * * + * 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. * + * * + ************************************************************************* +*/ +#include <signal.h> +#include "meanwhileprotocol.h" +#include "meanwhileplugin.h" +#include "meanwhileaccount.h" +#include "meanwhilecontact.h" +#include "meanwhilesession.h" +#include "kopetechatsession.h" +#include "kopetecontactlist.h" +#include "kopetepassword.h" + +#include <kaction.h> +#include <kpopupmenu.h> +#include <klocale.h> +#include <kconfigbase.h> +#include "kopeteaway.h" +#include <kinputdialog.h> +#include <kmessagebox.h> +#include <qdict.h> + +MeanwhileAccount::MeanwhileAccount( + MeanwhileProtocol *parent, + const QString &accountID, + const char *name) + : Kopete::PasswordedAccount(parent, accountID, 0, name) +{ + HERE; + m_meanwhileId = accountID; + m_session = 0L; + setMyself(new MeanwhileContact(m_meanwhileId, m_meanwhileId, this, + Kopete::ContactList::self()->myself())); + setOnlineStatus(parent->statusOffline); + infoPlugin = new MeanwhilePlugin(); +} + +MeanwhileAccount::~MeanwhileAccount() +{ + if (m_session) + delete m_session; +} + +void MeanwhileAccount::setPlugin(MeanwhilePlugin *plugin) +{ + delete infoPlugin; + infoPlugin = plugin; +} + +bool MeanwhileAccount::createContact( + const QString & contactId , + Kopete::MetaContact * parentContact) +{ + MeanwhileContact* newContact = new MeanwhileContact(contactId, + parentContact->displayName(), this, parentContact); + + MeanwhileProtocol *p = static_cast<MeanwhileProtocol *>(protocol()); + + if ((newContact != 0L) && (m_session != 0L) + && (myself()->onlineStatus() != + p->statusOffline)) + m_session->addContact(newContact); + + return newContact != 0L; +} + +void MeanwhileAccount::connectWithPassword(const QString &password) +{ + if (password.isEmpty()) { + disconnect(Kopete::Account::Manual); + return; + } + + if (m_session == 0L) { + m_session = new MeanwhileSession(this); + if (m_session == 0L) { + mwDebug() << "session creation failed" << endl; + return; + } + + QObject::connect(m_session, + SIGNAL(sessionStateChange(Kopete::OnlineStatus)), + this, SLOT(slotSessionStateChange(Kopete::OnlineStatus))); + QObject::connect(m_session, + SIGNAL(serverNotification(const QString &)), + this, SLOT(slotServerNotification(const QString&))); + + } + + if (m_session == 0L) { + mwDebug() << "No memory for session" << endl; + return; + } + + if (!m_session->isConnected() && !m_session->isConnecting()) + m_session->connect(password); + + m_session->setStatus(initialStatus()); +} + +void MeanwhileAccount::disconnect() +{ + disconnect(Manual); +} + +void MeanwhileAccount::disconnect(Kopete::Account::DisconnectReason reason) +{ + if (m_session == 0L) + return; + + MeanwhileProtocol *p = static_cast<MeanwhileProtocol *>(protocol()); + setAllContactsStatus(p->statusOffline); + disconnected(reason); + emit isConnectedChanged(); + + delete m_session; + m_session = 0L; +} + +KActionMenu * MeanwhileAccount::actionMenu() +{ + KActionMenu *menu = Kopete::Account::actionMenu(); + + menu->popupMenu()->insertSeparator(); + +#if 0 + menu->insert(new KAction(i18n("&Change Status Message"), QString::null, 0, + this, SLOT(meanwhileChangeStatus()), this, + "meanwhileChangeStatus")); + //infoPlugin->addCustomMenus(theMenu); +#endif + return menu; +} + +QString MeanwhileAccount::getServerName() +{ + return configGroup()->readEntry("Server"); +} + +int MeanwhileAccount::getServerPort() +{ + return configGroup()->readNumEntry("Port"); +} + +void MeanwhileAccount::setServerName(const QString &server) +{ + configGroup()->writeEntry("Server", server); +} + +void MeanwhileAccount::setServerPort(int port) +{ + configGroup()->writeEntry("Port", port); +} + +void MeanwhileAccount::setClientID(int client, int major, int minor) +{ + configGroup()->writeEntry("clientID", client); + configGroup()->writeEntry("clientVersionMajor", major); + configGroup()->writeEntry("clientVersionMinor", minor); +} + +void MeanwhileAccount::resetClientID() +{ + configGroup()->deleteEntry("clientID"); + configGroup()->deleteEntry("clientVersionMajor"); + configGroup()->deleteEntry("clientVersionMinor"); +} + +bool MeanwhileAccount::getClientIDParams(int *clientID, + int *verMajor, int *verMinor) +{ + bool custom_id = configGroup()->hasKey("clientID"); + + MeanwhileSession::getDefaultClientIDParams(clientID, verMajor, verMinor); + + if (custom_id) { + *clientID = configGroup()->readUnsignedNumEntry("clientID", *clientID); + *verMajor = configGroup()->readUnsignedNumEntry("clientVersionMajor", + *verMinor); + *verMinor = configGroup()->readUnsignedNumEntry("clientVersionMinor", + *verMinor); + } + + return custom_id; +} + +void MeanwhileAccount::slotServerNotification(const QString &mesg) +{ + KMessageBox::queuedMessageBox(0, KMessageBox::Error , mesg, + i18n("Meanwhile Plugin: Message from server"), KMessageBox::Notify); +} + +QString MeanwhileAccount::meanwhileId() const +{ + return m_meanwhileId; +} + +void MeanwhileAccount::setAway(bool away, const QString &reason) +{ + MeanwhileProtocol *p = static_cast<MeanwhileProtocol *>(protocol()); + setOnlineStatus(away ? p->statusIdle : p->statusOnline, reason); +} + +void MeanwhileAccount::setOnlineStatus(const Kopete::OnlineStatus &status, + const QString &reason) +{ + HERE; + Kopete::OnlineStatus oldstatus = myself()->onlineStatus(); + + mwDebug() << "From: " << oldstatus.description() << "(" << + oldstatus.internalStatus() << "):" << oldstatus.isDefinitelyOnline() + << endl; + mwDebug() << "To: " << status.description() << "(" << + status.internalStatus() << "):" << status.isDefinitelyOnline() << endl; + + if (oldstatus == status) + return; + + if (!oldstatus.isDefinitelyOnline() && status.isDefinitelyOnline()) { + connect(); + + } else if (oldstatus.isDefinitelyOnline() && !status.isDefinitelyOnline()) { + disconnect(Kopete::Account::Manual); + + } else if (m_session) + /* todo: check session state? */ + m_session->setStatus(status, reason); + + else + mwDebug() << "Trying to set status, but no session exists" << endl; + + /* we should set this on the callback below */ + //myself()->setOnlineStatus(status); +} + +void MeanwhileAccount::syncContactsToServer() +{ + if (m_session != 0L) + m_session->syncContactsToServer(); +} + +void MeanwhileAccount::slotSessionStateChange(Kopete::OnlineStatus status) +{ + HERE; + Kopete::OnlineStatus oldstatus = myself()->onlineStatus(); + myself()->setOnlineStatus(status); + + if (status.isDefinitelyOnline() != oldstatus.isDefinitelyOnline()) { + if (status.isDefinitelyOnline()) + m_session->addContacts(contacts()); + emit isConnectedChanged(); + } +} + +MeanwhileSession *MeanwhileAccount::session() +{ + return m_session; +} + +#include "meanwhileaccount.moc" diff --git a/kopete/protocols/meanwhile/meanwhileaccount.h b/kopete/protocols/meanwhile/meanwhileaccount.h new file mode 100644 index 00000000..d08b07c5 --- /dev/null +++ b/kopete/protocols/meanwhile/meanwhileaccount.h @@ -0,0 +1,121 @@ +/* + meanwhileaccount.h - meanwhile account + + Copyright (c) 2003-2004 by Sivaram Gottimukkala <[email protected]> + Copyright (c) 2005 by Jeremy Kerr <[email protected]> + + Kopete (c) 2002-2004 by the Kopete developers <[email protected]> + + ************************************************************************* + * * + * 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. * + * * + ************************************************************************* +*/ +#ifndef MEANWHILEACCOUNT_H +#define MEANWHILEACCOUNT_H + +#include <kopetepasswordedaccount.h> +#include "meanwhileprotocol.h" +#include "meanwhileplugin.h" + +class MeanwhileSession; + +/** + * A class to handle a single Meanwhile Account. + */ +class MeanwhileAccount : public Kopete::PasswordedAccount +{ + Q_OBJECT +public: + /** + * Create a new Meanwhile account + * @param protocol The MeanwhileProtocol that this acccount is for + * @param accountID The (meanwhile) account id of this account + * @param name The name of this account + */ + MeanwhileAccount(MeanwhileProtocol *protocol, const QString &accountID, + const char *name = 0L); + + ~MeanwhileAccount(); + + virtual bool createContact(const QString &contactId, + Kopete::MetaContact *parentContact); + + virtual void connectWithPassword(const QString &password); + + virtual void disconnect(); + + virtual void disconnect(Kopete::Account::DisconnectReason reason); + + virtual KActionMenu *actionMenu(); + + /** Get the server host name */ + QString getServerName(); + /** Get the server port */ + int getServerPort(); + /** Set the server host name */ + void setServerName(const QString &server); + /** Set the server port */ + void setServerPort(int port); + /** Provide an information plugin for this account */ + void setPlugin(MeanwhilePlugin *plugin); + + /** Set the client identification parameters for the sametime connection */ + void setClientID(int client, int major, int minor); + + /* returns true if custom IDs are in use, and populates the args */ + bool getClientIDParams(int *clientID, int *verMajor, int *verMinor); + + /** Reset client identification parameters to their defaults */ + void resetClientID(); + + MeanwhilePlugin *infoPlugin; + + /** + * Save the current contact list to the server + */ + void syncContactsToServer(); + + /** + * Get a reference to the meanwhile session object, if one exists + */ + MeanwhileSession *session(); + + /** + * Get the meanwhile id for this account + * @return The meanwhile ID for the account + */ + QString meanwhileId() const; + +public slots: + /** + * Called by the session to notify that the state has changed + */ + void slotSessionStateChange(Kopete::OnlineStatus status); + + /** + * Called by the session when a notification message has been received + */ + void slotServerNotification(const QString &mesg); + + /** Reimplemented from Kopete::Account */ + void setOnlineStatus(const Kopete::OnlineStatus& status, + const QString &reason = QString::null); + void setAway(bool away, const QString&reason = QString::null); + +private: + /** Current online status */ + Kopete::OnlineStatus status; + + /** A meanwhile session */ + MeanwhileSession *m_session; + + /* The user id for this account */ + QString m_meanwhileId; +}; + +#endif diff --git a/kopete/protocols/meanwhile/meanwhileaddcontactpage.cpp b/kopete/protocols/meanwhile/meanwhileaddcontactpage.cpp new file mode 100644 index 00000000..8709700b --- /dev/null +++ b/kopete/protocols/meanwhile/meanwhileaddcontactpage.cpp @@ -0,0 +1,74 @@ +/* + meanwhileaddcontactpage.cpp - add a contact + + Copyright (c) 2003-2004 by Sivaram Gottimukkala <[email protected]> + + Kopete (c) 2002-2004 by the Kopete developers <[email protected]> + + ************************************************************************* + * * + * 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. * + * * + ************************************************************************* +*/ +#include "meanwhileaddcontactpage.h" +#include <qpushbutton.h> +#include <qlayout.h> +#include <kopeteaccount.h> +#include <kopetemetacontact.h> +#include <qlineedit.h> + +#include "meanwhileprotocol.h" +#include "meanwhileaccount.h" +#include "meanwhileplugin.h" + +MeanwhileAddContactPage::MeanwhileAddContactPage( + QWidget* parent, + Kopete::Account *_account) + : AddContactPage(parent, 0L), theAccount(_account), + theParent(parent) +{ + ( new QVBoxLayout( this ) )->setAutoAdd( true ); + theDialog = new MeanwhileAddContactBase(this); + MeanwhileAccount *account = + static_cast<MeanwhileAccount *>(_account); + if (account->infoPlugin->canProvideMeanwhileId()) + { + QObject::connect(theDialog->btnFindUser, SIGNAL(clicked()), + SLOT(slotFindUser())); + } + else + theDialog->btnFindUser->setDisabled(true); + theDialog->show(); +} + +MeanwhileAddContactPage::~MeanwhileAddContactPage() +{ +} + +void MeanwhileAddContactPage::slotFindUser() +{ + MeanwhileAccount *account = + static_cast<MeanwhileAccount *>(theAccount); + account->infoPlugin->getMeanwhileId(theParent, + theDialog->contactID); +} + +bool MeanwhileAddContactPage::apply( + Kopete::Account* a, + Kopete::MetaContact* m ) +{ + QString displayName = theDialog->contactID->text(); + MeanwhileAccount* myAccount = static_cast<MeanwhileAccount*>(a); + return myAccount->addContact(displayName, m, Kopete::Account::ChangeKABC ); +} + +bool MeanwhileAddContactPage::validateData() +{ + return ! theDialog->contactID->text().isEmpty(); +} + +#include "meanwhileaddcontactpage.moc" diff --git a/kopete/protocols/meanwhile/meanwhileaddcontactpage.h b/kopete/protocols/meanwhile/meanwhileaddcontactpage.h new file mode 100644 index 00000000..889b2707 --- /dev/null +++ b/kopete/protocols/meanwhile/meanwhileaddcontactpage.h @@ -0,0 +1,45 @@ +/* + meanwhileaddcontactpage.h - add a contact + + Copyright (c) 2003-2004 by Sivaram Gottimukkala <[email protected]> + + Kopete (c) 2002-2004 by the Kopete developers <[email protected]> + + ************************************************************************* + * * + * 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. * + * * + ************************************************************************* +*/ +#ifndef MEANWHILEADDCONTACTPAGE_H +#define MEANWHILEADDCONTACTPAGE_H + +#include <addcontactpage.h> +#include "meanwhileaddcontactbase.h" + +namespace Kopete { class Account; } +namespace Kopete { class MetaContact; } + +class MeanwhileAddContactPage : public AddContactPage +{ + Q_OBJECT +public: + MeanwhileAddContactPage( QWidget* parent = 0, + Kopete::Account *account=0); + ~MeanwhileAddContactPage(); + + virtual bool apply(Kopete::Account* a, Kopete::MetaContact* m); + virtual bool validateData(); + +protected: + MeanwhileAddContactBase *theDialog; + Kopete::Account *theAccount; + QWidget *theParent; +public slots: + void slotFindUser(); +}; + +#endif diff --git a/kopete/protocols/meanwhile/meanwhilecontact.cpp b/kopete/protocols/meanwhile/meanwhilecontact.cpp new file mode 100644 index 00000000..fd30bc46 --- /dev/null +++ b/kopete/protocols/meanwhile/meanwhilecontact.cpp @@ -0,0 +1,132 @@ +/* + meanwhilecontact.cpp - a meanwhile contact + + Copyright (c) 2003-2004 by Sivaram Gottimukkala <[email protected]> + + Kopete (c) 2002-2004 by the Kopete developers <[email protected]> + + ************************************************************************* + * * + * 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. * + * * + ************************************************************************* +*/ + +#include <kaction.h> +#include <kdebug.h> +#include <klocale.h> + +#include "kopeteaccount.h" +#include "kopetechatsessionmanager.h" +#include "kopetemetacontact.h" + +#include "meanwhileprotocol.h" +#include "meanwhilesession.h" +#include "meanwhileaccount.h" +#include "meanwhilecontact.h" +#include "meanwhileplugin.h" + +MeanwhileContact::MeanwhileContact(QString userId, QString nickname, + MeanwhileAccount *account, Kopete::MetaContact *parent) + : Kopete::Contact(account, userId, parent) +{ + setNickName(nickname); + m_msgManager = 0L; + m_meanwhileId = userId; + setOnlineStatus(static_cast<MeanwhileProtocol *>(account->protocol()) + ->statusOffline); +} + +MeanwhileContact::~MeanwhileContact() +{ +} + +bool MeanwhileContact::isReachable() +{ + return isOnline(); +} + +void MeanwhileContact::serialize(QMap<QString, QString> &serializedData, + QMap<QString, QString> &addressBookData) +{ + Kopete::Contact::serialize(serializedData, addressBookData); +} + +void MeanwhileContact::showContactSettings() +{ +} + +void MeanwhileContact::slotUserInfo() +{ + MeanwhileAccount *theAccount = static_cast<MeanwhileAccount *>( account()); + theAccount->infoPlugin->showUserInfo(m_meanwhileId); +} + +Kopete::ChatSession* MeanwhileContact::manager(CanCreateFlags canCreate) +{ + if (m_msgManager != 0L || canCreate == Kopete::Contact::CannotCreate) + return m_msgManager; + + QPtrList<Kopete::Contact> contacts; + contacts.append(this); + m_msgManager = Kopete::ChatSessionManager::self()-> + create(account()->myself(), contacts, protocol()); + + connect(m_msgManager, + SIGNAL(messageSent(Kopete::Message&, Kopete::ChatSession*)), + this, SLOT(sendMessage(Kopete::Message&))); + + connect(m_msgManager, SIGNAL(myselfTyping(bool)), + this, SLOT(slotSendTyping(bool))); + + connect(m_msgManager, SIGNAL(destroyed()), + this, SLOT(slotChatSessionDestroyed())); + + return m_msgManager; +} + +QString MeanwhileContact::meanwhileId() const +{ + return m_meanwhileId; +} + +void MeanwhileContact::sendMessage(Kopete::Message &message) +{ + static_cast<MeanwhileAccount *>(account())->session()->sendMessage(message); +} + +void MeanwhileContact::slotSendTyping(bool isTyping) +{ + static_cast<MeanwhileAccount *>(account())->session()-> + sendTyping(this, isTyping); +} + +void MeanwhileContact::receivedMessage(const QString &message) +{ + Kopete::ContactPtrList contactList; + contactList.append(account()->myself()); + Kopete::Message kmessage(this, contactList, message, + Kopete::Message::Inbound); + + manager(Kopete::Contact::CanCreate)->appendMessage(kmessage); +} + +void MeanwhileContact::sync(unsigned int changed) +{ + if (changed) + static_cast<MeanwhileAccount *>(account())->syncContactsToServer(); +} + +void MeanwhileContact::slotChatSessionDestroyed() +{ + m_msgManager->deref(); + m_msgManager = 0L; +} + +#include "meanwhilecontact.moc" + +// vim: set noet ts=4 sts=4 sw=4: + diff --git a/kopete/protocols/meanwhile/meanwhilecontact.h b/kopete/protocols/meanwhile/meanwhilecontact.h new file mode 100644 index 00000000..eface094 --- /dev/null +++ b/kopete/protocols/meanwhile/meanwhilecontact.h @@ -0,0 +1,68 @@ +/* + meanwhilecontact.h - a contact + + Copyright (c) 2003-2004 by Sivaram Gottimukkala <[email protected]> + + Kopete (c) 2002-2004 by the Kopete developers <[email protected]> + + ************************************************************************* + * * + * 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. * + * * + ************************************************************************* +*/ +#ifndef MEANWHILECONTACT_H +#define MEANWHILECONTACT_H + +#include <qmap.h> +#include "kopetecontact.h" +#include "kopetemessage.h" +#include "meanwhileaccount.h" + +class KAction; +class KActionCollection; +namespace Kopete { class Account; } +namespace Kopete { class ChatSession; } +namespace Kopete { class MetaContact; } + +class MeanwhileContact : public Kopete::Contact +{ + Q_OBJECT +public: + + MeanwhileContact(QString userId, QString nickname, + MeanwhileAccount *account, Kopete::MetaContact *parent); + ~MeanwhileContact(); + + virtual bool isReachable(); + + virtual void serialize(QMap<QString, QString> &serializedData, + QMap<QString, QString> &addressBookData); + + virtual Kopete::ChatSession *manager( + CanCreateFlags canCreate = CanCreate); + + QString meanwhileId() const; + + virtual void sync(unsigned int changed = 0xff); + +public slots: + + void sendMessage( Kopete::Message &message ); + void receivedMessage( const QString &message ); + virtual void slotUserInfo(); + +protected slots: + void showContactSettings(); + void slotChatSessionDestroyed(); + void slotSendTyping(bool isTyping); + +private: + QString m_meanwhileId; + Kopete::ChatSession *m_msgManager; +}; + +#endif diff --git a/kopete/protocols/meanwhile/meanwhileeditaccountwidget.cpp b/kopete/protocols/meanwhile/meanwhileeditaccountwidget.cpp new file mode 100644 index 00000000..f3d05710 --- /dev/null +++ b/kopete/protocols/meanwhile/meanwhileeditaccountwidget.cpp @@ -0,0 +1,194 @@ +/* + meanwhileeditaccountwidget.cpp - edit an account + + Copyright (c) 2003-2004 by Sivaram Gottimukkala <[email protected]> + + Kopete (c) 2002-2004 by the Kopete developers <[email protected]> + + ************************************************************************* + * * + * 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. * + * * + ************************************************************************* +*/ +#include <qlayout.h> +#include <qlineedit.h> +#include <qcheckbox.h> +#include <qpushbutton.h> +#include <qspinbox.h> +#include <qcombobox.h> +#include <kdebug.h> +#include <kopeteaccount.h> +#include <kopetepasswordwidget.h> +#include <kmessagebox.h> +#include <klocale.h> +#include "meanwhileprotocol.h" +#include "meanwhileaccount.h" +#include "meanwhileeditaccountwidget.h" +#include "meanwhilesession.h" + +#define DEFAULT_SERVER "messaging.opensource.ibm.com" +#define DEFAULT_PORT 1533 + +void MeanwhileEditAccountWidget::setupClientList() +{ + const struct MeanwhileClientID *id; + int i = 0; + + for (id = MeanwhileSession::getClientIDs(); id->name; id++, i++) { + QString name = QString("%1 (0x%2)") + .arg(QString(id->name)) + .arg(id->id, 0, 16); + + mClientID->insertItem(name, i); + + if (id->id == mwLogin_MEANWHILE) + mClientID->setCurrentItem(i); + } +} + +void MeanwhileEditAccountWidget::selectClientListItem(int selectedID) +{ + const struct MeanwhileClientID *id; + int i = 0; + + for (id = MeanwhileSession::getClientIDs(); id->name; id++, i++) { + if (id->id == selectedID) { + mClientID->setCurrentItem(i); + break; + } + } +} + +MeanwhileEditAccountWidget::MeanwhileEditAccountWidget( + QWidget* parent, + Kopete::Account* theAccount, + MeanwhileProtocol *theProtocol) + : MeanwhileEditAccountBase(parent), + KopeteEditAccountWidget( theAccount ) +{ + protocol = theProtocol; + + /* setup client identifier combo box */ + setupClientList(); + + if (account()) + { + int clientID, verMajor, verMinor; + bool useCustomID; + + mScreenName->setText(account()->accountId()); + mScreenName->setReadOnly(true); + mScreenName->setDisabled(true); + mPasswordWidget->load(&static_cast<MeanwhileAccount*>(account())->password()); + mAutoConnect->setChecked(account()->excludeConnect()); + + MeanwhileAccount *myAccount = static_cast<MeanwhileAccount *>(account()); + useCustomID = myAccount->getClientIDParams(&clientID, + &verMajor, &verMinor); + + mServerName->setText(myAccount->getServerName()); + mServerPort->setValue(myAccount->getServerPort()); + + if (useCustomID) { + selectClientListItem(clientID); + mClientVersionMajor->setValue(verMajor); + mClientVersionMinor->setValue(verMinor); + chkCustomClientID->setChecked(true); + } + + } + else + { + slotSetServer2Default(); + } + + QObject::connect(btnServerDefaults, SIGNAL(clicked()), + SLOT(slotSetServer2Default())); + + show(); +} + +MeanwhileEditAccountWidget::~MeanwhileEditAccountWidget() +{ +} + + +Kopete::Account* MeanwhileEditAccountWidget::apply() +{ + if(!account()) + setAccount(new MeanwhileAccount(protocol, mScreenName->text())); + + MeanwhileAccount *myAccount = static_cast<MeanwhileAccount *>(account()); + + myAccount->setExcludeConnect(mAutoConnect->isChecked()); + + mPasswordWidget->save(&static_cast<MeanwhileAccount*>(account())->password()); + + myAccount->setServerName(mServerName->text()); + myAccount->setServerPort(mServerPort->value()); + + if (chkCustomClientID->isChecked()) { + const struct MeanwhileClientID *ids = MeanwhileSession::getClientIDs(); + myAccount->setClientID(ids[mClientID->currentItem()].id, + mClientVersionMajor->value(), + mClientVersionMinor->value()); + } else { + myAccount->resetClientID(); + } + + return myAccount; +} + +bool MeanwhileEditAccountWidget::validateData() +{ + if(mScreenName->text().isEmpty()) + { + KMessageBox::queuedMessageBox(this, KMessageBox::Sorry, + i18n("<qt>You must enter a valid screen name.</qt>"), + i18n("Meanwhile Plugin")); + return false; + } + if( !mPasswordWidget->validate() ) + { + KMessageBox::queuedMessageBox(this, KMessageBox::Sorry, + i18n("<qt>You must deselect password remembering or enter a valid password.</qt>"), + i18n("Meanwhile Plugin")); + return false; + } + if (mServerName->text().isEmpty()) + { + KMessageBox::queuedMessageBox(this, KMessageBox::Sorry, + i18n("<qt>You must enter the server's hostname/ip address.</qt>"), + i18n("Meanwhile Plugin")); + return false; + } + if (mServerPort->text() == 0) + { + KMessageBox::queuedMessageBox(this, KMessageBox::Sorry, + i18n("<qt>0 is not a valid port number.</qt>"), + i18n("Meanwhile Plugin")); + return false; + } + return true; +} + +void MeanwhileEditAccountWidget::slotSetServer2Default() +{ + int clientID, verMajor, verMinor; + + MeanwhileSession::getDefaultClientIDParams(&clientID, + &verMajor, &verMinor); + + mServerName->setText(DEFAULT_SERVER); + mServerPort->setValue(DEFAULT_PORT); + chkCustomClientID->setChecked(false); + selectClientListItem(clientID); + mClientVersionMajor->setValue(verMajor); + mClientVersionMinor->setValue(verMinor); +} + +#include "meanwhileeditaccountwidget.moc" diff --git a/kopete/protocols/meanwhile/meanwhileeditaccountwidget.h b/kopete/protocols/meanwhile/meanwhileeditaccountwidget.h new file mode 100644 index 00000000..9e05465b --- /dev/null +++ b/kopete/protocols/meanwhile/meanwhileeditaccountwidget.h @@ -0,0 +1,51 @@ +/* + meanwhileeditaccountwidget.h - edit an account + + Copyright (c) 2003-2004 by Sivaram Gottimukkala <[email protected]> + + Kopete (c) 2002-2004 by the Kopete developers <[email protected]> + + ************************************************************************* + * * + * 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. * + * * + ************************************************************************* +*/ +#ifndef MEANWHILEEDITACCOUNTWIDGET_H +#define MEANWHILEEDITACCOUNTWIDGET_H + +#include <qwidget.h> +#include <editaccountwidget.h> +#include "meanwhileeditaccountbase.h" + +class QVBoxLayout; +namespace Kopete { class Account; } + +class MeanwhileEditAccountWidget : + public MeanwhileEditAccountBase, + public KopeteEditAccountWidget +{ +Q_OBJECT +public: + MeanwhileEditAccountWidget( QWidget* parent, + Kopete::Account* account, + MeanwhileProtocol *protocol); + + ~MeanwhileEditAccountWidget(); + + virtual Kopete::Account* apply(); + + virtual bool validateData(); +protected slots: + void slotSetServer2Default(); +protected: + MeanwhileProtocol *protocol; +private: + void setupClientList(); + void selectClientListItem(int selectedID); +}; + +#endif diff --git a/kopete/protocols/meanwhile/meanwhileplugin.cpp b/kopete/protocols/meanwhile/meanwhileplugin.cpp new file mode 100644 index 00000000..d8f617cb --- /dev/null +++ b/kopete/protocols/meanwhile/meanwhileplugin.cpp @@ -0,0 +1,37 @@ +/* + meanwhileplugin.cpp - a plugin to provide more functions + + Copyright (c) 2003-2004 by Sivaram Gottimukkala <[email protected]> + + Kopete (c) 2002-2004 by the Kopete developers <[email protected]> + + ************************************************************************* + * * + * 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. * + * * + ************************************************************************* +*/ +#include <qwidget.h> +#include <qlineedit.h> +#include "meanwhileplugin.h" + +void MeanwhilePlugin::getMeanwhileId(QWidget * /*parent*/, + QLineEdit * /*fillThis*/) +{ +} + +bool MeanwhilePlugin::canProvideMeanwhileId() +{ + return false; +} + +void MeanwhilePlugin::showUserInfo(const QString &/*userid*/) +{ +} + +void MeanwhilePlugin::addCustomMenus(KActionMenu *menu) +{ +} diff --git a/kopete/protocols/meanwhile/meanwhileplugin.h b/kopete/protocols/meanwhile/meanwhileplugin.h new file mode 100644 index 00000000..b2ddbdcb --- /dev/null +++ b/kopete/protocols/meanwhile/meanwhileplugin.h @@ -0,0 +1,47 @@ +/* + meanwhileplugin.h - provide helpers for meanwhile from an external plugin + + Copyright (c) 2003-2004 by Sivaram Gottimukkala <[email protected]> + + Kopete (c) 2002-2004 by the Kopete developers <[email protected]> + + ************************************************************************* + * * + * 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. * + * * + ************************************************************************* +*/ +#ifndef __MEANWHILE_PLUGIN_H__ +#define __MEANWHILE_PLUGIN_H__ + +#include "qstring.h" +#include <kaction.h> + +class QLineEdit; + +class MeanwhilePlugin +{ +public: + /* do something when the find button on add contact is hit + * - like do lookups in company databases + * when done fill 'fillThis' with the id of the contact + */ + virtual void getMeanwhileId(QWidget *parent,QLineEdit *fillThis); + /* can this plugin provide the above functionality */ + virtual bool canProvideMeanwhileId(); + + /* show user info has been selected - the meanwhile server doesnt + * seem to have any info...maybe you can find it somewhere else + */ + virtual void showUserInfo(const QString &userid); + + /* if you want to provide more functions on the rightclick dropdown + * menu...implement this + */ + virtual void addCustomMenus(KActionMenu *menu); +}; + +#endif diff --git a/kopete/protocols/meanwhile/meanwhileprotocol.cpp b/kopete/protocols/meanwhile/meanwhileprotocol.cpp new file mode 100644 index 00000000..434de2f3 --- /dev/null +++ b/kopete/protocols/meanwhile/meanwhileprotocol.cpp @@ -0,0 +1,126 @@ +/* + meanwhileprotocol.cpp - the meanwhile protocol + + Copyright (c) 2003-2004 by Sivaram Gottimukkala <[email protected]> + + Kopete (c) 2002-2004 by the Kopete developers <[email protected]> + + ************************************************************************* + * * + * 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. * + * * + ************************************************************************* +*/ +#include "meanwhileprotocol.h" +#include "meanwhileaddcontactpage.h" +#include "meanwhileeditaccountwidget.h" +#include "meanwhileaccount.h" +#include <kgenericfactory.h> +#include "kopeteaccountmanager.h" +#include "kopeteglobal.h" +#include "kopeteonlinestatusmanager.h" + +#include "mw_common.h" + +typedef KGenericFactory<MeanwhileProtocol> MeanwhileProtocolFactory; +K_EXPORT_COMPONENT_FACTORY(kopete_meanwhile, + MeanwhileProtocolFactory("kopete_meanwhile")) + +MeanwhileProtocol::MeanwhileProtocol(QObject* parent, const char *name, + const QStringList &/*args*/) +: Kopete::Protocol(MeanwhileProtocolFactory::instance(), parent, name), + + statusOffline(Kopete::OnlineStatus::Offline, 25, this, 0, QString::null, + i18n("Offline"), i18n("Offline"), + Kopete::OnlineStatusManager::Offline, + Kopete::OnlineStatusManager::DisabledIfOffline), + + statusOnline(Kopete::OnlineStatus::Online, 25, this, mwStatus_ACTIVE, + QString::null, i18n("Online"), i18n("Online"), + Kopete::OnlineStatusManager::Online, 0), + + statusAway(Kopete::OnlineStatus::Away, 20, this, mwStatus_AWAY, + "meanwhile_away", i18n("Away"), i18n("Away"), + Kopete::OnlineStatusManager::Away, + Kopete::OnlineStatusManager::HasAwayMessage), + + statusBusy(Kopete::OnlineStatus::Away, 25, this, mwStatus_BUSY, + "meanwhile_dnd", i18n("Busy"), i18n("Busy"), + Kopete::OnlineStatusManager::Busy, + Kopete::OnlineStatusManager::HasAwayMessage), + + statusIdle(Kopete::OnlineStatus::Away, 30, this, mwStatus_AWAY, + "meanwhile_idle", i18n("Idle"), i18n("Idle"), + Kopete::OnlineStatusManager::Idle, 0), + + statusAccountOffline(Kopete::OnlineStatus::Offline, 0, this, 0, + QString::null, i18n("Account Offline")), + + statusMessage(QString::fromLatin1("statusMessage"), + i18n("Status Message"), QString::null, false, true), + + awayMessage(Kopete::Global::Properties::self()->awayMessage()) +{ + HERE; + + addAddressBookField("messaging/meanwhile", Kopete::Plugin::MakeIndexField); +} + +MeanwhileProtocol::~MeanwhileProtocol() +{ +} + +AddContactPage * MeanwhileProtocol::createAddContactWidget(QWidget *parent, + Kopete::Account *account ) +{ + return new MeanwhileAddContactPage(parent, account); +} + +KopeteEditAccountWidget * MeanwhileProtocol::createEditAccountWidget( + Kopete::Account *account, QWidget *parent ) +{ + return new MeanwhileEditAccountWidget(parent, account, this); +} + +Kopete::Account *MeanwhileProtocol::createNewAccount(const QString &accountId) +{ + return new MeanwhileAccount(this, accountId, accountId.ascii()); +} + +Kopete::Contact *MeanwhileProtocol::deserializeContact( + Kopete::MetaContact *metaContact, + const QMap<QString, + QString> &serializedData, + const QMap<QString, QString> & /* addressBookData */ ) +{ + QString contactId = serializedData[ "contactId" ]; + QString accountId = serializedData[ "accountId" ]; + + MeanwhileAccount *theAccount = + static_cast<MeanwhileAccount*>( + Kopete::AccountManager::self()-> + findAccount(pluginId(), accountId)); + + if(!theAccount) + { + return 0; + } + + theAccount->addContact(contactId, metaContact, Kopete::Account::DontChangeKABC); + return theAccount->contacts()[contactId]; +} + +const Kopete::OnlineStatus MeanwhileProtocol::accountOfflineStatus() +{ + return statusAccountOffline; +} + +const Kopete::OnlineStatus MeanwhileProtocol::lookupStatus( + enum Kopete::OnlineStatusManager::Categories cats) +{ + return Kopete::OnlineStatusManager::self()->onlineStatus(this, cats); +} +#include "meanwhileprotocol.moc" diff --git a/kopete/protocols/meanwhile/meanwhileprotocol.h b/kopete/protocols/meanwhile/meanwhileprotocol.h new file mode 100644 index 00000000..aa7a9861 --- /dev/null +++ b/kopete/protocols/meanwhile/meanwhileprotocol.h @@ -0,0 +1,77 @@ +/* + meanwhileprotocl.h - the meanwhile protocol definition + + Copyright (c) 2005 by Jeremy Kerr <[email protected]> + Copyright (c) 2003-2004 by Sivaram Gottimukkala <[email protected]> + + Kopete (c) 2002-2004 by the Kopete developers <[email protected]> + + ************************************************************************* + * * + * 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. * + * * + ************************************************************************* +*/ +#ifndef MEANWHILEPROTOCOL_H +#define MEANWHILEPROTOCOL_H + +#include <kopeteprotocol.h> + +#include "kopetecontact.h" +#include "kopetemetacontact.h" +#include "kopeteonlinestatus.h" +#include "kopeteonlinestatusmanager.h" +#include "addcontactpage.h" + +#include <kdebug.h> +#define MEANWHILE_DEBUG 14200 +#define HERE kdDebug(MEANWHILE_DEBUG) << k_funcinfo << endl +#define mwDebug() kdDebug(MEANWHILE_DEBUG) + +class MeanwhileAccount; +class MeanwhileEditAccountWidget; +class MeanwhileAddContactPage; + +class MeanwhileProtocol : public Kopete::Protocol +{ + Q_OBJECT +public: + MeanwhileProtocol(QObject *parent, const char *name, + const QStringList &args); + + ~MeanwhileProtocol(); + + virtual AddContactPage *createAddContactWidget(QWidget *parent, + Kopete::Account *account); + + virtual KopeteEditAccountWidget *createEditAccountWidget( + Kopete::Account *account, QWidget *parent); + + virtual Kopete::Account *createNewAccount(const QString &accountId); + + virtual Kopete::Contact *deserializeContact( + Kopete::MetaContact *metaContact, + const QMap<QString,QString> &serializedData, + const QMap<QString, QString> &addressBookData); + + const Kopete::OnlineStatus accountOfflineStatus(); + + const Kopete::OnlineStatus lookupStatus( + enum Kopete::OnlineStatusManager::Categories cats); + + const Kopete::OnlineStatus statusOffline; + const Kopete::OnlineStatus statusOnline; + const Kopete::OnlineStatus statusAway; + const Kopete::OnlineStatus statusBusy; + const Kopete::OnlineStatus statusIdle; + const Kopete::OnlineStatus statusAccountOffline; + + Kopete::ContactPropertyTmpl statusMessage; + Kopete::ContactPropertyTmpl awayMessage; + +}; + +#endif diff --git a/kopete/protocols/meanwhile/meanwhilesession.cpp b/kopete/protocols/meanwhile/meanwhilesession.cpp new file mode 100644 index 00000000..974ca4af --- /dev/null +++ b/kopete/protocols/meanwhile/meanwhilesession.cpp @@ -0,0 +1,965 @@ +/* + meanwhilesession.cpp - interface to the 'C' meanwhile library + + Copyright (c) 2003-2004 by Sivaram Gottimukkala <[email protected]> + Copyright (c) 2005 by Jeremy Kerr <[email protected]> + + Kopete (c) 2002-2004 by the Kopete developers <[email protected]> + + ************************************************************************* + * * + * 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. * + * * + ************************************************************************* +*/ + +#include <string.h> +#include <stdlib.h> +#include <kmessagebox.h> +#include <klocale.h> + +#include <kopetepassword.h> +#include <kopetechatsession.h> +#include <kopetegroup.h> +#include <kopetecontactlist.h> +#include "meanwhilesession.h" +#include "meanwhileprotocol.h" + +#include <mw_channel.h> +#include <mw_message.h> +#include <mw_error.h> +#include <mw_service.h> +#include <mw_session.h> +#include <mw_srvc_aware.h> +#include <mw_srvc_conf.h> +#include <mw_srvc_im.h> +#include <mw_srvc_store.h> +#include <mw_cipher.h> +#include <mw_st_list.h> + +#define set_session_handler(a,b) sessionHandler.a = _handleSession ## b +#define set_aware_handler(a,b) awareHandler.a = _handleAware ## b +#define set_aware_list_handler(a,b) \ + awareListHandler.a = _handleAwareList ## b +#define set_im_handler(a,b) imHandler.a = _handleIm ## b + +#define get_protocol() (static_cast<MeanwhileProtocol *>(account->protocol())) + +static struct MeanwhileClientID ids[] = { + { mwLogin_LIB, "Lotus Binary Library" }, + { mwLogin_JAVA_WEB, "Lotus Java Applet", }, + { mwLogin_BINARY, "Lotus Binary App", }, + { mwLogin_JAVA_APP, "Lotus Java App", }, + { mwLogin_LINKS, "Sametime Links", }, + + { mwLogin_NOTES_6_5, "Notes 6.5", }, + { mwLogin_NOTES_6_5_3, "Notes 6.5.3", }, + { mwLogin_NOTES_7_0_beta, "Notes 7.0 beta", }, + { mwLogin_NOTES_7_0, "Notes 7.0", }, + { mwLogin_ICT, "ICT", }, + { mwLogin_ICT_1_7_8_2, "ICT 1.7.8.2", }, + { mwLogin_ICT_SIP, "ICT SIP", }, + { mwLogin_NOTESBUDDY_4_14, "NotesBuddy 4.14", }, + { mwLogin_NOTESBUDDY_4_15, "NotesBuddy 4.15" }, + { mwLogin_NOTESBUDDY_4_16, "NotesBuddy 4.16" }, + { mwLogin_SANITY, "Sanity", }, + { mwLogin_ST_PERL, "ST Perl", }, + { mwLogin_PMR_ALERT, "PMR Alert", }, + { mwLogin_TRILLIAN, "Trillian", }, + { mwLogin_TRILLIAN_IBM, "Trillian (IBM)", }, + { mwLogin_MEANWHILE, "Meanwhile Library", }, + { 0, NULL }, +}; + +MeanwhileSession::MeanwhileSession(MeanwhileAccount *account) +{ + HERE; + this->account = account; + session = 0L; + socket = 0L; + state = mwSession_STOPPED; + + /* set up main session hander */ + memset(&sessionHandler, 0, sizeof(sessionHandler)); + set_session_handler(io_write, IOWrite); + set_session_handler(io_close, IOClose); + set_session_handler(on_stateChange, StateChange); + set_session_handler(on_setPrivacyInfo, SetPrivacyInfo); + set_session_handler(on_setUserStatus, SetUserStatus); + set_session_handler(on_admin, Admin); + set_session_handler(on_announce, Announce); + set_session_handler(clear, Clear); + + session = mwSession_new(&sessionHandler); + mwSession_setClientData(session, this, 0L); + + /* set up the aware service */ + memset(&awareHandler, 0, sizeof(awareHandler)); + set_aware_handler(on_attrib, Attrib); + + awareService = mwServiceAware_new(session, &awareHandler); + mwSession_addService(session, (struct mwService *)awareService); + + /* create an aware list */ + memset(&awareListHandler, 0, sizeof(awareListHandler)); + set_aware_list_handler(on_aware, Aware); + set_aware_list_handler(on_attrib, Attrib); + awareList = mwAwareList_new(awareService, &awareListHandler); + mwAwareList_setClientData(awareList, this, 0L); + + /* set up an im service */ + memset(&imHandler, 0, sizeof(imHandler)); + set_im_handler(conversation_opened, ConvOpened); + set_im_handler(conversation_closed, ConvClosed); + set_im_handler(conversation_recv, ConvReceived); + imHandler.place_invite = 0L; + imHandler.clear = 0L; + + imService = mwServiceIm_new(session, &imHandler); + mwService_setClientData((struct mwService *)imService, this, 0L); + mwSession_addService(session, (struct mwService *) imService); + + /* add resolve service */ + resolveService = mwServiceResolve_new(session); + mwService_setClientData((struct mwService *)resolveService, this, 0L); + mwSession_addService(session, (struct mwService *) resolveService); + + /* storage service */ + storageService = mwServiceStorage_new(session); + mwService_setClientData((struct mwService *)storageService, this, 0L); + mwSession_addService(session, (struct mwService *) storageService); + +#if 0 + /* conference service setup - just declines invites for now. */ + memset(&conf_handler, 0, sizeof(conf_handler)); + conf_handler.on_invited = _conference_invite; + + srvc_conf = mwServiceConference_new(session, &conf_handler); + mwService_setClientData((struct mwService *)srvc_conf, this, 0L); + mwSession_addService(session, (struct mwService *) srvc_conf); +#endif + + /* add a necessary cipher */ + mwSession_addCipher(session, mwCipher_new_RC2_40(session)); + mwSession_addCipher(session, mwCipher_new_RC2_128(session)); +} + +MeanwhileSession::~MeanwhileSession() +{ + HERE; + if (isConnected() || isConnecting()) + disconnect(); + + mwSession_removeService(session, mwService_STORAGE); + mwSession_removeService(session, mwService_RESOLVE); + mwSession_removeService(session, mwService_IM); + mwSession_removeService(session, mwService_AWARE); + + mwAwareList_free(awareList); + mwService_free(MW_SERVICE(storageService)); + mwService_free(MW_SERVICE(resolveService)); + mwService_free(MW_SERVICE(imService)); + mwService_free(MW_SERVICE(awareService)); + mwCipher_free(mwSession_getCipher(session, mwCipher_RC2_40)); + mwCipher_free(mwSession_getCipher(session, mwCipher_RC2_128)); + + mwSession_free(session); + + if (socket) + delete socket; +} + +void MeanwhileSession::getDefaultClientIDParams(int *clientID, + int *verMajor, int *verMinor) +{ + *clientID = mwLogin_MEANWHILE; + *verMajor = MW_PROTOCOL_VERSION_MAJOR; + *verMinor = MW_PROTOCOL_VERSION_MINOR; +} + +/* external interface called by meanwhileaccount */ +void MeanwhileSession::connect(QString password) +{ + int port, clientID, versionMajor, versionMinor; + bool useCustomID; + QString host; + + HERE; + + host = account->getServerName(); + port = account->getServerPort(); + useCustomID = account->getClientIDParams(&clientID, + &versionMajor, &versionMinor); + + KExtendedSocket *sock = new KExtendedSocket(host, port, + KExtendedSocket::bufferedSocket); + + if (sock->connect()) { + KMessageBox::queuedMessageBox(0, KMessageBox::Error, + i18n( "Could not connect to server"), i18n("Meanwhile Plugin"), + KMessageBox::Notify); + delete sock; + return; + } + socket = sock; + /* we want to receive signals when there is data to read */ + sock->enableRead(true); + QObject::connect(sock, SIGNAL(readyRead()), this, + SLOT(slotSocketDataAvailable())); + QObject::connect(sock, SIGNAL(closed(int)), this, + SLOT(slotSocketClosed(int))); + + /* set login details */ + mwSession_setProperty(session, mwSession_AUTH_USER_ID, + g_strdup(account->meanwhileId().ascii()), g_free); + mwSession_setProperty(session, mwSession_AUTH_PASSWORD, + g_strdup(password.ascii()), g_free); + + /* set client type parameters */ + if (useCustomID) { + mwSession_setProperty(session, mwSession_CLIENT_TYPE_ID, + GUINT_TO_POINTER(clientID), NULL); + mwSession_setProperty(session, mwSession_CLIENT_VER_MAJOR, + GUINT_TO_POINTER(versionMajor), NULL); + mwSession_setProperty(session, mwSession_CLIENT_VER_MINOR, + GUINT_TO_POINTER(versionMinor), NULL); + } + + mwDebug() << "ids: " + << mwSession_getProperty(session, mwSession_CLIENT_TYPE_ID) << " v" + << mwSession_getProperty(session, mwSession_CLIENT_VER_MAJOR) << "." + << mwSession_getProperty(session, mwSession_CLIENT_VER_MINOR) << + endl; + + /* go!! */ + mwSession_start(session); +} + +void MeanwhileSession::disconnect() +{ + HERE; + if (state == mwSession_STOPPED || state == mwSession_STOPPING) + return; + + mwSession_stop(session, ERR_SUCCESS); +} + +bool MeanwhileSession::isConnected() +{ + return mwSession_isStarted(session); +} + +bool MeanwhileSession::isConnecting() +{ + return mwSession_isStarting(session); +} + +static void free_id_block(void *data, void *p) +{ + if (p != 0L || data == 0L) + return; + struct mwAwareIdBlock *id = (struct mwAwareIdBlock *)data; + free(id->user); + free(id); +} + +void MeanwhileSession::addContacts(const QDict<Kopete::Contact>& contacts) +{ + HERE; + QDictIterator<Kopete::Contact> it(contacts); + GList *buddies = 0L; + + /** Convert our QDict of kopete contact to a GList of meanwhile buddies */ + for( ; it.current(); ++it) { + MeanwhileContact *contact = + static_cast<MeanwhileContact *>(it.current()); + struct mwAwareIdBlock *id = (struct mwAwareIdBlock *) + malloc(sizeof(*id)); + if (id == 0L) + continue; + id->user = strdup(contact->meanwhileId().ascii()); + id->community = 0L; + id->type = mwAware_USER; + buddies = g_list_append(buddies, id); + } + + mwAwareList_addAware(awareList, buddies); + + g_list_foreach(buddies, free_id_block, 0L); + g_list_free(buddies); +} + +/* private functions used only by the meanwhile session object */ +void MeanwhileSession::addContact(const Kopete::Contact *contact) +{ + HERE; + struct mwAwareIdBlock id = { mwAware_USER, + strdup(static_cast<const MeanwhileContact *>(contact) + ->meanwhileId().ascii()), + 0L }; + + GList *buddies = g_list_prepend(0L, &id); + mwAwareList_addAware(awareList, buddies); + g_list_free(buddies); + free(id.user); +} + +int MeanwhileSession::sendMessage(Kopete::Message &message) +{ + HERE; + MeanwhileContact *contact = + static_cast<MeanwhileContact *>(message.to().first()); + if (!contact) { + mwDebug() << "No target for message!" <<endl; + return 0; + } + + struct mwIdBlock target = { strdup(contact->meanwhileId().ascii()), 0L }; + struct mwConversation *conv; + + conv = mwServiceIm_getConversation(imService, &target); + free(target.user); + if (conv == 0L) { + mwDebug() << "No target for conversation with '" + << contact->meanwhileId() << "'" << endl; + return 0; + } + + struct ConversationData *convdata = (struct ConversationData *) + mwConversation_getClientData(conv); + + if (convdata == 0L) { + convdata = createConversationData(conv, contact, true); + if (convdata == 0L) { + mwDebug() << "No memory for conversation data!" << endl; + return 0; + } + } + + /* if there's other messages in the queue, or the conversation isn't open, + * then append to the queue instead of sending right away */ + if ((convdata->queue && !convdata->queue->isEmpty()) || + !mwConversation_isOpen(conv)) { + convdata->queue->append(message); + mwConversation_open(conv); + + } else if (!mwConversation_send(conv, mwImSend_PLAIN, + message.plainBody().ascii())) { + convdata->chat->appendMessage(message); + convdata->chat->messageSucceeded(); + } + return 1; +} + +void MeanwhileSession::sendTyping(MeanwhileContact *contact, bool isTyping) +{ + HERE; + struct mwIdBlock target = { strdup(contact->meanwhileId().ascii()), 0L }; + struct mwConversation *conv; + + conv = mwServiceIm_getConversation(imService, &target); + free(target.user); + if (conv == 0L) + return; + + if (mwConversation_isOpen(conv)) + mwConversation_send(conv, mwImSend_TYPING, (void *)isTyping); +} + +void MeanwhileSession::setStatus(Kopete::OnlineStatus status, + const QString msg) +{ + HERE; + mwDebug() << "setStatus: " << status.description() << "(" + << status.internalStatus() << ")" << endl; + if (status.internalStatus() == 0) + return; + + struct mwUserStatus stat; + mwUserStatus_clone(&stat, mwSession_getUserStatus(session)); + + free(stat.desc); + + stat.status = (mwStatusType)status.internalStatus(); + if (msg.isNull() || msg.isEmpty()) + stat.desc = strdup(status.description().ascii()); + else + stat.desc = strdup(msg.ascii()); + + mwSession_setUserStatus(session, &stat); + /* will free stat.desc */ + mwUserStatus_clear(&stat); +} + +void MeanwhileSession::syncContactsToServer() +{ + HERE; + struct mwSametimeList *list = mwSametimeList_new(); + + /* set up a fallback group for top-level contacts */ + struct mwSametimeGroup *topstgroup = mwSametimeGroup_new(list, + mwSametimeGroup_DYNAMIC, "People"); + mwSametimeGroup_setOpen(topstgroup, true); + + QDictIterator<Kopete::Contact> it(account->contacts()); + for( ; it.current(); ++it ) { + MeanwhileContact *contact = + static_cast<MeanwhileContact *>(it.current()); + + /* Find the group that the metacontact is in */ + Kopete::MetaContact *mc = contact->metaContact(); + /* myself doesn't have a metacontact */ + if (mc == 0L) + continue; + + Kopete::Group *contactgroup = mc->groups().getFirst(); + if (contactgroup == 0L) + continue; + + if (contactgroup->type() == Kopete::Group::Temporary) + continue; + + struct mwSametimeGroup *stgroup; + if (contactgroup->type() == Kopete::Group::TopLevel) { + stgroup = topstgroup; + } else { + /* find (or create) a matching sametime list group */ + stgroup = mwSametimeList_findGroup(list, + contactgroup->displayName().ascii()); + if (stgroup == 0L) { + stgroup = mwSametimeGroup_new(list, mwSametimeGroup_DYNAMIC, + contactgroup->displayName().ascii()); + } + mwSametimeGroup_setOpen(stgroup, contactgroup->isExpanded()); + mwSametimeGroup_setAlias(stgroup, + contactgroup->pluginData(account->protocol(), "alias") + .ascii()); + } + + /* now add the user (by IDBlock) */ + struct mwIdBlock id = + { (gchar*)contact->meanwhileId().ascii(), 0L }; + struct mwSametimeUser *stuser = mwSametimeUser_new(stgroup, + mwSametimeUser_NORMAL, &id); + + mwSametimeUser_setAlias(stuser, contact->nickName().ascii()); + } + + /* store! */ + struct mwPutBuffer *buf = mwPutBuffer_new(); + struct mwStorageUnit *unit = mwStorageUnit_new(mwStore_AWARE_LIST); + struct mwOpaque *opaque = mwStorageUnit_asOpaque(unit); + + mwSametimeList_put(buf, list); + mwPutBuffer_finalize(opaque, buf); + + mwServiceStorage_save(storageService, unit, NULL, NULL, NULL); + + mwSametimeList_free(list); +} + +void MeanwhileSession::syncContactsFromServer() +{ + struct mwStorageUnit *unit = mwStorageUnit_new(mwStore_AWARE_LIST); + mwServiceStorage_load(storageService, unit, &_handleStorageLoad, 0L, 0L); +} + +#define MEANWHILE_SESSION_BUFSIZ 4096 + +void MeanwhileSession::slotSocketDataAvailable() +{ + HERE; + guchar *buf; + Q_LONG bytesRead; + + if (socket == 0L) + return; + + if (!(buf = (guchar *)malloc(MEANWHILE_SESSION_BUFSIZ))) { + mwDebug() << "buffer malloc failed" << endl; + return; + } + + while (socket && socket->bytesAvailable() > 0) { + bytesRead = socket->readBlock((char *)buf, MEANWHILE_SESSION_BUFSIZ); + if (bytesRead < 0) + break; + mwSession_recv(session, buf, (unsigned int)bytesRead); + } + free(buf); +} + +void MeanwhileSession::slotSocketClosed(int reason) +{ + HERE; + + if (reason & KExtendedSocket::involuntary) + emit serverNotification( + QString("Lost connection with Meanwhile server")); + + if (socket) { + delete socket; + socket = 0L; + } + + mwSession_stop(session, 0x00); +} + + +Kopete::OnlineStatus MeanwhileSession::convertStatus(int mstatus) +{ + MeanwhileProtocol *protocol = + static_cast<MeanwhileProtocol *>(account->protocol()); + + switch (mstatus) { + case mwStatus_ACTIVE: + return protocol->statusOnline; + break; + case mwStatus_IDLE: + return protocol->statusIdle; + break; + case mwStatus_AWAY: + return protocol->statusAway; + break; + case mwStatus_BUSY: + return protocol->statusBusy; + break; + case 0: + return protocol->statusOffline; + break; + default: + mwDebug() << "unknown status lookup: " << mstatus << endl; + } + return protocol->statusOffline; +} + +void MeanwhileSession::resolveContactNickname(MeanwhileContact *contact) +{ + /* @todo: FIXME: leak! */ + char *id = strdup(contact->meanwhileId().ascii()); + GList *query = g_list_prepend(NULL, id); + mwServiceResolve_resolve(resolveService, query, mwResolveFlag_USERS, + _handleResolveLookupResults, contact, NULL); +} + +QString MeanwhileSession::getNickName(struct mwLoginInfo *logininfo) +{ + if (logininfo == 0L || logininfo->user_name == 0L) + return QString::null; + return getNickName(logininfo->user_name); +} + +QString MeanwhileSession::getNickName(QString name) +{ + + int index = name.find(" - "); + if (index != -1) + name = name.remove(0, index + 3); + index = name.find('/'); + if (index != -1) + name = name.left(index); + + return name; +} + +MeanwhileContact *MeanwhileSession::conversationContact( + struct mwConversation *conv) +{ + struct mwIdBlock *target = mwConversation_getTarget(conv); + if (target == 0L || target->user == 0L) { + return 0L; + } + QString user(target->user); + + MeanwhileContact *contact = + static_cast<MeanwhileContact *>(account->contacts()[user]); + + struct mwLoginInfo *logininfo = mwConversation_getTargetInfo(conv); + QString name = getNickName(logininfo); + + if (!contact) { + account->addContact(user, name, 0L, Kopete::Account::Temporary); + contact = static_cast<MeanwhileContact *>(account->contacts()[user]); + } else + contact->setNickName(name); + + return contact; +} + +/* priave session handling functions, called by libmeanwhile callbacks */ +void MeanwhileSession::handleSessionStateChange( + enum mwSessionState state, gpointer data) +{ + HERE; + this->state = state; + + switch (state) { + case mwSession_STARTING: + case mwSession_HANDSHAKE: + case mwSession_HANDSHAKE_ACK: + case mwSession_LOGIN: + case mwSession_LOGIN_REDIR: + case mwSession_LOGIN_CONT: + case mwSession_LOGIN_ACK: + break; + + case mwSession_STARTED: + { + struct mwUserStatus stat = { mwStatus_ACTIVE, 0, 0L }; + mwSession_setUserStatus(session, &stat); + struct mwLoginInfo *logininfo = mwSession_getLoginInfo(session); + if (logininfo) { + account->myself()->setNickName(getNickName(logininfo)); + } + syncContactsFromServer(); + } + break; + + case mwSession_STOPPING: + { + unsigned int info = GPOINTER_TO_UINT(data); + if (info & ERR_FAILURE) { + if (info == INCORRECT_LOGIN) + account->password().setWrong(); + char *reason = mwError(info); + emit serverNotification(QString(reason)); + free(reason); + } + } + + emit sessionStateChange( + static_cast<MeanwhileProtocol *>(account->protocol()) + ->statusOffline); + break; + + case mwSession_STOPPED: + break; + + case mwSession_UNKNOWN: + default: + mwDebug() << "Unhandled state change " << state << endl; + } +} + +int MeanwhileSession::handleSessionIOWrite(const guchar *buffer, + gsize count) +{ + HERE; + + if (socket == 0L) + return 1; + + int remaining, retval = 0; + for (remaining = count; remaining > 0; remaining -= retval) { + retval = socket->writeBlock((char *)buffer, count); + if (retval <= 0) + return 1; + } + socket->flush(); + return 0; +} + +void MeanwhileSession::handleSessionAdmin(const char *text) +{ + HERE; + emit serverNotification(QString(text)); +} + +void MeanwhileSession::handleSessionAnnounce(struct mwLoginInfo *from, + gboolean /* may_reply */, const char *text) +{ + HERE; + QString message; + message.sprintf("Announcement from %s:\n%s", from->user_id, text); + emit serverNotification(message); +} + +void MeanwhileSession::handleSessionSetUserStatus() +{ + struct mwUserStatus *userstatus = mwSession_getUserStatus(session); + emit sessionStateChange(convertStatus((unsigned int)userstatus->status)); +} + +void MeanwhileSession::handleSessionSetPrivacyInfo() +{ +} + +void MeanwhileSession::handleSessionIOClose() +{ + HERE; + + if (socket == 0L) + return; + + QObject::disconnect(socket, SIGNAL(closed(int)), + this, SLOT(slotSocketClosed(int))); + socket->flush(); + socket->closeNow(); + + delete socket; + socket = 0L; +} + +void MeanwhileSession::handleSessionClear() +{ +} + +void MeanwhileSession::handleAwareAttrib(struct mwAwareAttribute * /* attrib */) +{ + HERE; +} + +void MeanwhileSession::handleAwareListAware(struct mwAwareSnapshot *snapshot) +{ + HERE; + MeanwhileContact *contact = static_cast<MeanwhileContact *> + (account->contacts()[snapshot->id.user]); + + if (contact == 0L) + return; + + /* use the setUserStatus callback for status updates for myself. */ + if (contact == account->myself()) + return; + + contact->setProperty(get_protocol()->statusMessage, snapshot->status.desc); + contact->setProperty(get_protocol()->awayMessage, snapshot->status.desc); + + Kopete::OnlineStatus onlinestatus; + if (snapshot->online) { + onlinestatus = convertStatus(snapshot->status.status); + resolveContactNickname(contact); + } else { + onlinestatus = convertStatus(0); + } + + contact->setOnlineStatus(onlinestatus); + +#if 0 + /* Commented out in previous kopete/meanwhile plugin for some reason, + * but has still been ported to the new API. + */ + time_t idletime = 0; + if (snapshot->status.status == mwStatus_IDLE) { + idletime = (snapshot->status.time == 0xdeadbeef) ? + 0 : snapshot->status.time; + if (idletime != 0) { + contact->setStatusDescription(statusDesc + "[" + + QString::number(idletime/60)+" mins]"); + } + } else + contact->setStatusDescription(snapshot->status.desc); +#endif +} + +void MeanwhileSession::handleAwareListAttrib(struct mwAwareIdBlock * /* id */, + struct mwAwareAttribute * /* attrib */) +{ + HERE; +} + +struct MeanwhileSession::ConversationData + *MeanwhileSession::createConversationData( + struct mwConversation *conv, MeanwhileContact *contact, + bool createQueue) +{ + struct ConversationData *cd = new ConversationData(); + + if (cd == 0L) + return 0L; + + cd->contact = contact; + cd->chat = contact->manager(Kopete::Contact::CanCreate); + cd->chat->ref(); + if (createQueue) + cd->queue = new QValueList<Kopete::Message>(); + + mwConversation_setClientData(conv, cd, 0L); + + return cd; +} + +void MeanwhileSession::handleImConvOpened(struct mwConversation *conv) +{ + HERE; + + struct ConversationData *convdata = + (struct ConversationData *)mwConversation_getClientData(conv); + + if (convdata == 0L) { + /* a new conversation */ + convdata = createConversationData(conv, conversationContact(conv)); + + if (convdata == 0L) { + mwDebug() << "No memory for conversation data!" << endl; + return; + } + + } else if (convdata->queue && !convdata->queue->isEmpty()) { + /* send any messages that were waiting for the conversation to open */ + QValueList<Kopete::Message>::iterator it; + for (it = convdata->queue->begin(); it != convdata->queue->end(); + ++it) { + mwConversation_send(conv, mwImSend_PLAIN, + (*it).plainBody().ascii()); + convdata->chat->appendMessage(*it); + convdata->chat->messageSucceeded(); + } + convdata->queue->clear(); + delete convdata->queue; + convdata->queue = 0L; + } + resolveContactNickname(convdata->contact); +} + +void MeanwhileSession::handleImConvClosed(struct mwConversation *conv, + guint32) +{ + HERE; + + ConversationData *convdata = + (ConversationData *)mwConversation_getClientData(conv); + + if (!convdata) + return; + + mwConversation_setClientData(conv, 0L, 0L); + + convdata->chat->removeContact(convdata->contact); + convdata->chat->deref(); + convdata->chat = 0L; + if (convdata->queue != 0L) { + convdata->queue->clear(); + delete convdata->queue; + convdata->queue = 0L; + } + free(convdata); +} + +void MeanwhileSession::handleImConvReceived(struct mwConversation *conv, + enum mwImSendType type, gconstpointer msg) +{ + HERE; + ConversationData *convdata = + (ConversationData *)mwConversation_getClientData(conv); + + if (!convdata) + return; + + switch (type) { + case mwImSend_PLAIN: + { + Kopete::Message message(convdata->contact, account->myself(), + QString((char *)msg), Kopete::Message::Inbound); + convdata->chat->appendMessage(message); + } + break; + case mwImSend_TYPING: + convdata->chat->receivedTypingMsg(convdata->contact); + break; + default: + mwDebug() << "Unable to handle message type: " << type << endl; + } +} + +void MeanwhileSession::handleResolveLookupResults( + struct mwServiceResolve * /* srvc */, guint32 /* id */, + guint32 /* code */, GList *results, gpointer data) +{ + struct mwResolveResult *result; + struct mwResolveMatch *match; + + if (results == 0L) + return; + if ((result = (struct mwResolveResult *)results->data) == 0L) + return; + + if (result->matches == 0L) + return; + if ((match = (struct mwResolveMatch *)result->matches->data) == 0L) + return; + + mwDebug() << "resolve lookup returned '" << match->name << "'" << endl; + + MeanwhileContact *contact = (MeanwhileContact *)data; + if (contact == 0L) + return; + + contact->setNickName(getNickName(match->name)); +} + +void MeanwhileSession::handleStorageLoad(struct mwServiceStorage * /* srvc */, + guint32 result, struct mwStorageUnit *item, gpointer /* data */) +{ + HERE; + if (result != ERR_SUCCESS) { + mwDebug() << "contact list load returned " << result << endl; + return; + } + + struct mwGetBuffer *buf = mwGetBuffer_wrap(mwStorageUnit_asOpaque(item)); + struct mwSametimeList *list = mwSametimeList_new(); + mwSametimeList_get(buf, list); + + GList *gl, *glf, *cl, *clf; + + Kopete::ContactList *contactlist = Kopete::ContactList::self(); + + for (glf = gl = mwSametimeList_getGroups(list); gl; gl = gl->next) { + struct mwSametimeGroup *stgroup = (struct mwSametimeGroup *)gl->data; + + Kopete::Group *group = + contactlist->findGroup(mwSametimeGroup_getName(stgroup)); + group->setPluginData(account->protocol(), "alias", + mwSametimeGroup_getAlias(stgroup)); + + for (clf = cl = mwSametimeGroup_getUsers(stgroup); cl; cl = cl->next) { + struct mwSametimeUser *stuser = (struct mwSametimeUser *)cl->data; + + MeanwhileContact *contact = static_cast<MeanwhileContact *> + (account->contacts()[mwSametimeUser_getUser(stuser)]); + + if (contact != 0L) + continue; + + account->addContact(mwSametimeUser_getUser(stuser), + mwSametimeUser_getAlias(stuser), group, + Kopete::Account::ChangeKABC); + } + g_list_free(clf); + } + g_list_free(glf); + + mwSametimeList_free(list); +} + +const struct MeanwhileClientID *MeanwhileSession::getClientIDs() +{ + return ids; +} + +#if 0 +MEANWHILE_HOOK_CONFERENCE(conference_invite, + (struct mwConference *conf, struct mwLoginInfo *inviter, + const char *invite), + (conf, inviter, invite)) +{ + HERE; + QString message; + + message.sprintf("%s has invited you to a conference called \"%s\"\n" + "However, this version of the meanwhile plugin does " + "not support conferences, so the invitiation has been declined.", + inviter->user_id, invite); + + mwConference_reject(conf, ERR_SUCCESS, + "Sorry, my client doesn't support conferences!"); + KMessageBox::queuedMessageBox(0, KMessageBox::Sorry , message, + i18n("Meanwhile Plugin: Conference invitation"), + KMessageBox::Notify); +} +#endif +#include "meanwhilesession.moc" diff --git a/kopete/protocols/meanwhile/meanwhilesession.h b/kopete/protocols/meanwhile/meanwhilesession.h new file mode 100644 index 00000000..0e2a3558 --- /dev/null +++ b/kopete/protocols/meanwhile/meanwhilesession.h @@ -0,0 +1,350 @@ +/* + meanwhilesession.h - interface to the 'C' meanwhile session + + Copyright (c) 2005 by Jeremy Kerr <[email protected]> + + ************************************************************************* + * * + * 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. * + * * + ************************************************************************* +*/ +#ifndef MEANWHILESESSION_H +#define MEANWHILESESSION_H + +#include "meanwhileaccount.h" +#include "meanwhilecontact.h" +#include <kextendedsocket.h> + +#include <mw_session.h> +#include <mw_service.h> +#include <mw_srvc_aware.h> +#include <mw_srvc_im.h> +#include <mw_srvc_resolve.h> + +struct MeanwhileClientID { + int id; + const char *name; +}; + +/** + * A class to handle libmeanwhile session management. + */ +class MeanwhileSession : public QObject +{ + Q_OBJECT + +public: + /** + * Create a session. By default, the session is not connected - you will + * need to call login() to initiate the connection process. + * @param account The account that the connection is for + */ + MeanwhileSession(MeanwhileAccount *account); + + /** + * Destroy the session + */ + ~MeanwhileSession(); + + /** + * Connect to the server. This will open a socket and start login. Note that + * the connection process is ascychronous - a loginDone() signal will be + * emitted when sucessfully logged in. + */ + void connect(QString password); + + /** + * Disconnect from the server. + */ + void disconnect(); + + /** + * Set our (the local contact's) online status. The internalStatus of the + * state argument will be used to define the state message we send - it + * should be one of the Status enum fields (and not Offline) + * @param state the new state of the local user + * @param msg a custom message to use, if required + */ + void setStatus(Kopete::OnlineStatus status, + const QString msg = QString::null); + + /** + * Add a single contact to be registered for status updates + * @param contact The contact to register + */ + void addContact(const Kopete::Contact *contact); + + /** + * Add a list of contacts to be registered for status updates + * @param contact The list of contacts to register + */ + void addContacts(const QDict<Kopete::Contact>& contacts); + + /** + * Send a message (with recipient specified). + * @param message The message to send + * @return non-zero if the message could be sent + */ + int sendMessage(Kopete::Message &message); + + /** + * Send a typing notification to a contact + * @param contact The contact to notify + * @param isTyping If true, the typing notification is set + */ + void sendTyping(MeanwhileContact *contact, bool isTyping); + + /** + * Determine if the session is connected to the server + * @return true if the session is connected + */ + bool isConnected(); + + /** + * Determine if the session is in the process of connecting to the server + * @return true if the session is connecting + */ + bool isConnecting(); + + static const struct MeanwhileClientID *getClientIDs(); + + static void getDefaultClientIDParams(int *clientID, + int *verMajor, int *verMinor); +signals: + /** + * Emitted when the status of the connection changes + * @param status The new status of the session + */ + void sessionStateChange(Kopete::OnlineStatus status); + + /** + * Emitted when a notification is received from the server, or other + * out-of-band data (eg, the password is incorrect). + * @param mesgString A description of the notification + */ + void serverNotification(const QString &mesgString); + +private: + /** Main libmeanwhile session object */ + struct mwSession *session; + + /** Session handler */ + struct mwSessionHandler sessionHandler; + + /** Aware service */ + struct mwServiceAware *awareService; + + /** Aware handler */ + struct mwAwareHandler awareHandler; + + /** Aware List Handler */ + struct mwAwareListHandler awareListHandler; + + /** The aware list */ + struct mwAwareList *awareList; + + /** Aware service */ + struct mwServiceIm *imService; + + /** Aware handler */ + struct mwImHandler imHandler; + + /** Resolve service */ + struct mwServiceResolve *resolveService; + + /** Storage service, for contact list */ + struct mwServiceStorage *storageService; + + /** Last recorded meanwhile state */ + enum mwSessionState state; + + /** The kopete account that this library is for */ + MeanwhileAccount *account; + + /** socket to the server */ + KExtendedSocket *socket; + + /* These structures are stored in the libmeanwhile 'ClientData' fields */ + + /** Stored in the mwConversation struct */ + struct ConversationData { + MeanwhileContact *contact; + Kopete::ChatSession *chat; + QValueList<Kopete::Message> *queue; + }; + + /** (To be) stored in the mwConference struct */ + struct ConferenceData { + Kopete::ChatSession *chatsession; + }; + + /** + * Initialise the conversation data struct for a conversation, and store it + * in the meanwhile conversation object + * @param conv the meanwhile conversation object + * @param contact the contact that the conversation is with + * @param createQueue whether a message queue is required for this + * conversation + * @return The created conversation data struct + */ + struct ConversationData *createConversationData( + struct mwConversation *conv, MeanwhileContact *contact, + bool createQueue = false); + + /** + * Get the contact for a conversation + * @param conv the meanwhile conversation + * @return the contact that this conversation is held with + */ + MeanwhileContact *conversationContact(struct mwConversation *conv); + + /** + * Convert a libmeanwhile-type status into one of the MeanwhileProtocol + * statuses + * @param mstatus The internal status to convert + * @return The Meanwhile status + */ + Kopete::OnlineStatus convertStatus(int mstatus); + + /** + * Parse the nickname of a libmeanwhile contact. From what I've seen, + * usernames are in the format: + * <userid> - <name>/<domain>/<domain> + * @param name the extened username to parse + * @return just the name part of the username info + */ + QString getNickName(QString name); + + /** + * Convenience method to call the above from a mwLoginInfo struct. All is + * checked for null. + * @param logininfo the login info for a contact + * @return just the name part of the login info data + */ + QString getNickName(struct mwLoginInfo *logininfo); + + /** + * Resolve a contact to find (and set) the display name. This requires the + * session to be connected to use the meanwhile resolve service. + * @param contact The contact to resolve + */ + void resolveContactNickname(MeanwhileContact *contact); + +public: + void syncContactsToServer(); + void syncContactsFromServer(); + +private slots: + + /** Notify the library that data is available on the socket */ + void slotSocketDataAvailable(); + + /** + * Notify the library that the socket has been closed + * @param reason the reason for closing + */ + void slotSocketClosed(int reason); + +private: + /* ugly callbacks for libmeanwhile interface. These declare a static method + * to proxy the callback from libmeanwhile to a call to the MeanwhileSession + */ + +#define declare_session_handler_type(type, func, args, ...) \ + static type _handleSession ## func ( \ + struct mwSession *mwsession, __VA_ARGS__) { \ + MeanwhileSession *session = \ + (MeanwhileSession *)mwSession_getClientData(mwsession); \ + return session->handleSession ## func args; \ + }; \ + type handleSession ## func(__VA_ARGS__) +#define declare_session_handler(func, args, ...) \ + static void _handleSession ## func ( \ + struct mwSession *mwsession, ## __VA_ARGS__) { \ + MeanwhileSession *session = \ + (MeanwhileSession *)mwSession_getClientData(mwsession); \ + session->handleSession ## func args; \ + }; \ + void handleSession ## func(__VA_ARGS__) + + declare_session_handler_type(int, IOWrite, (buf, len), + const guchar *buf, gsize len); + declare_session_handler(IOClose,()); + declare_session_handler(Clear,()); + declare_session_handler(StateChange, (state, info), + enum mwSessionState state, gpointer info); + declare_session_handler(SetPrivacyInfo,()); + declare_session_handler(SetUserStatus,()); + declare_session_handler(Admin, (text), const char *text); + declare_session_handler(Announce, (from, may_reply, text), + struct mwLoginInfo *from, gboolean may_reply, const char *text); + +#define declare_aware_handler(func, args, ...) \ + static void _handleAware ## func ( \ + struct mwServiceAware *srvc, ## __VA_ARGS__) { \ + MeanwhileSession *session = (MeanwhileSession *) \ + mwService_getClientData((struct mwService *)srvc); \ + return session->handleAware ## func args; \ + }; \ + void handleAware ## func(__VA_ARGS__) + + declare_aware_handler(Attrib, (attrib), struct mwAwareAttribute *attrib); + declare_aware_handler(Clear,()); + +#define declare_aware_list_handler(func, args, ...) \ + static void _handleAwareList ## func ( \ + struct mwAwareList *list, ## __VA_ARGS__){ \ + MeanwhileSession *session = (MeanwhileSession *) \ + mwAwareList_getClientData(list); \ + return session->handleAwareList ## func args; \ + }; \ + void handleAwareList ## func(__VA_ARGS__) + + declare_aware_list_handler(Aware, (snapshot), + struct mwAwareSnapshot *snapshot); + declare_aware_list_handler(Attrib, (id, attrib), + struct mwAwareIdBlock *id, struct mwAwareAttribute *attrib); + declare_aware_list_handler(Clear,()); + +#define declare_im_handler(func, args, ...) \ + static void _handleIm ## func ( \ + struct mwConversation *conv, ## __VA_ARGS__) { \ + MeanwhileSession *session = (MeanwhileSession *) \ + mwService_getClientData( \ + (struct mwService *)mwConversation_getService(conv)); \ + return session->handleIm ## func args; \ + }; \ + void handleIm ## func (struct mwConversation *conv, ## __VA_ARGS__) + + declare_im_handler(ConvOpened, (conv)); + declare_im_handler(ConvClosed, (conv, err), guint32 err); + declare_im_handler(ConvReceived, (conv, type, msg), + enum mwImSendType type, gconstpointer msg); + + /* resolve service */ + static void _handleResolveLookupResults(struct mwServiceResolve *srvc, + guint32 id, guint32 code, GList *results, gpointer data) { + MeanwhileSession *session = (MeanwhileSession *) + mwService_getClientData(MW_SERVICE(srvc)); + session->handleResolveLookupResults(srvc, id, code, results, data); + }; + void handleResolveLookupResults(struct mwServiceResolve *srvc, guint32 id, + guint32 code, GList *results, gpointer data); + + /* storage service */ + static void _handleStorageLoad(struct mwServiceStorage *srvc, + guint32 result, struct mwStorageUnit *item, gpointer data) { + MeanwhileSession *session = (MeanwhileSession *) + mwService_getClientData(MW_SERVICE(srvc)); + session->handleStorageLoad(srvc, result, item, data); + }; + void handleStorageLoad(struct mwServiceStorage *srvc, + guint32 result, struct mwStorageUnit *item, gpointer data); +}; + +#endif + diff --git a/kopete/protocols/meanwhile/ui/Makefile.am b/kopete/protocols/meanwhile/ui/Makefile.am new file mode 100644 index 00000000..466f68b2 --- /dev/null +++ b/kopete/protocols/meanwhile/ui/Makefile.am @@ -0,0 +1,8 @@ +METASOURCES = AUTO + +noinst_LTLIBRARIES = libkopetemeanwhileui.la +AM_CPPFLAGS = $(KOPETE_INCLUDES) \ + -I$(srcdir)/.. \ + $(all_includes) + +libkopetemeanwhileui_la_SOURCES = empty.cpp meanwhileeditaccountbase.ui meanwhileaddcontactbase.ui diff --git a/kopete/protocols/meanwhile/ui/empty.cpp b/kopete/protocols/meanwhile/ui/empty.cpp new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/kopete/protocols/meanwhile/ui/empty.cpp diff --git a/kopete/protocols/meanwhile/ui/meanwhileaddcontactbase.ui b/kopete/protocols/meanwhile/ui/meanwhileaddcontactbase.ui new file mode 100644 index 00000000..d146a8ed --- /dev/null +++ b/kopete/protocols/meanwhile/ui/meanwhileaddcontactbase.ui @@ -0,0 +1,111 @@ +<!DOCTYPE UI><UI version="3.1" stdsetdef="1"> +<class>MeanwhileAddContactBase</class> +<widget class="QWidget"> + <property name="name"> + <cstring>Form1</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>396</width> + <height>347</height> + </rect> + </property> + <property name="caption"> + <string>Add Sametime Contact</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout53</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="text"> + <string>&Userid:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>contactID</cstring> + </property> + <property name="toolTip" stdset="0"> + <string>The user id of the contact you would like to add.</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The user id of the contact you would like to add.</string> + </property> + </widget> + <widget class="QLineEdit"> + <property name="name"> + <cstring>contactID</cstring> + </property> + <property name="toolTip" stdset="0"> + <string>The user id of the contact you would like to add.</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The user id of the contact you would like to add.</string> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>btnFindUser</cstring> + </property> + <property name="text"> + <string>&Find</string> + </property> + <property name="toolTip" stdset="0"> + <string>Find Userid</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Find Userid</string> + </property> + </widget> + </hbox> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel3_2</cstring> + </property> + <property name="text"> + <string><i>(for example: johndoe)</i></string> + </property> + <property name="alignment"> + <set>AlignVCenter|AlignRight</set> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>spacer1</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>80</height> + </size> + </property> + </spacer> + </vbox> +</widget> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/kopete/protocols/meanwhile/ui/meanwhileeditaccountbase.ui b/kopete/protocols/meanwhile/ui/meanwhileeditaccountbase.ui new file mode 100644 index 00000000..2f160039 --- /dev/null +++ b/kopete/protocols/meanwhile/ui/meanwhileeditaccountbase.ui @@ -0,0 +1,437 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>MeanwhileEditAccountBase</class> +<widget class="QWidget"> + <property name="name"> + <cstring>MeanwhileEditAccountBase</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>640</width> + <height>450</height> + </rect> + </property> + <property name="caption"> + <string>Edit Meanwhile Account</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QTabWidget"> + <property name="name"> + <cstring>tabWidget11</cstring> + </property> + <widget class="QWidget"> + <property name="name"> + <cstring>tab</cstring> + </property> + <attribute name="title"> + <string>B&asic Setup</string> + </attribute> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QGroupBox"> + <property name="name"> + <cstring>groupBox53</cstring> + </property> + <property name="title"> + <string>Account Information</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout81</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>label1</cstring> + </property> + <property name="text"> + <string>Meanwhile &username:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>mScreenName</cstring> + </property> + <property name="toolTip" stdset="0"> + <string>Your Sametime userid</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Your Sametime userid</string> + </property> + </widget> + <widget class="QLineEdit"> + <property name="name"> + <cstring>mScreenName</cstring> + </property> + <property name="toolTip" stdset="0"> + <string>Your Sametime userid</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Your Sametime userid</string> + </property> + </widget> + </hbox> + </widget> + <widget class="Kopete::UI::PasswordWidget"> + <property name="name"> + <cstring>mPasswordWidget</cstring> + </property> + </widget> + <widget class="QCheckBox"> + <property name="name"> + <cstring>mAutoConnect</cstring> + </property> + <property name="text"> + <string>E&xclude from connect all</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Check to disable automatic connection. If checked, you may connect to this account manually using the icon in the bottom of the main Kopete window</string> + </property> + </widget> + </vbox> + </widget> + </vbox> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>tab</cstring> + </property> + <attribute name="title"> + <string>Connection</string> + </attribute> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QGroupBox"> + <property name="name"> + <cstring>groupBox54</cstring> + </property> + <property name="title"> + <string>Connection Preferences</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout21</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout56</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>lblServer</cstring> + </property> + <property name="text"> + <string>Ser&ver:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>mServerName</cstring> + </property> + <property name="toolTip" stdset="0"> + <string>The IP address or hostname of the Sametime server you wish to connect to.</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The IP address or hostname of the Sametime server you wish to connect to.</string> + </property> + </widget> + <widget class="QLineEdit"> + <property name="name"> + <cstring>mServerName</cstring> + </property> + <property name="toolTip" stdset="0"> + <string>The IP address or hostname of the Sametime server you wish to connect to.</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The IP address or hostname of the Sametime server you wish to connect to.</string> + </property> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout57</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>lblPort</cstring> + </property> + <property name="text"> + <string>Po&rt:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>mServerPort</cstring> + </property> + <property name="toolTip" stdset="0"> + <string>The port on the Sametime server that you would like to connect to.</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The port on the Sametime server that you would like to connect to. Usually this is 1533.</string> + </property> + </widget> + <widget class="QSpinBox"> + <property name="name"> + <cstring>mServerPort</cstring> + </property> + <property name="maxValue"> + <number>65534</number> + </property> + <property name="minValue"> + <number>1</number> + </property> + <property name="value"> + <number>1533</number> + </property> + <property name="toolTip" stdset="0"> + <string>The port on the Sametime server that you would like to connect to.</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The port on the Sametime server that you would like to connect to. Usually this is 1533.</string> + </property> + </widget> + </hbox> + </widget> + </hbox> + </widget> + <widget class="QGroupBox"> + <property name="name"> + <cstring>groupBox5</cstring> + </property> + <property name="title"> + <string>Client Identifier</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QCheckBox"> + <property name="name"> + <cstring>chkCustomClientID</cstring> + </property> + <property name="text"> + <string>Use custom client identifier</string> + </property> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout17</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QComboBox" row="0" column="1"> + <property name="name"> + <cstring>mClientID</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>lblClientIdentifier</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Client identifier</string> + </property> + <property name="buddy" stdset="0"> + <cstring>mClientID</cstring> + </property> + </widget> + <widget class="QLayoutWidget" row="1" column="1"> + <property name="name"> + <cstring>layout13</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QSpinBox"> + <property name="name"> + <cstring>mClientVersionMajor</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="maxValue"> + <number>65535</number> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>lblVersionSeparator</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>.</string> + </property> + <property name="alignment"> + <set>AlignCenter</set> + </property> + </widget> + <widget class="QSpinBox"> + <property name="name"> + <cstring>mClientVersionMinor</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="maxValue"> + <number>65535</number> + </property> + </widget> + </hbox> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>lblClientVersion</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Client version (major.minor)</string> + </property> + <property name="buddy" stdset="0"> + <cstring>mClientVersionMajor</cstring> + </property> + </widget> + </grid> + </widget> + </vbox> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>btnServerDefaults</cstring> + </property> + <property name="text"> + <string>Restore &Defaults</string> + </property> + <property name="toolTip" stdset="0"> + <string>Restore the server and port values to their defaults.</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Restore the server and port values to their defaults.</string> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>spacer3</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>31</height> + </size> + </property> + </spacer> + </vbox> + </widget> + </vbox> + </widget> + </widget> + </vbox> +</widget> +<customwidgets> + <customwidget> + <class>Kopete::UI::PasswordWidget</class> + <header location="local">kopetepasswordwidget.h</header> + <sizehint> + <width>50</width> + <height>50</height> + </sizehint> + <container>0</container> + <sizepolicy> + <hordata>1</hordata> + <verdata>0</verdata> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + <pixmap>image0</pixmap> + <signal>changed()</signal> + </customwidget> +</customwidgets> +<images> + <image name="image0"> + <data format="PNG" length="866">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b0000032949444154388db59531681b6714c77f32373c8186ef0305eea005093258900eca26d30e3174a8a807d1c9ee940e5d4a276f09a414e22974ee609a4c75a0857a70a20c199ce93424e43414aee0c26910dc8105f7410df706413a7c915551db049a3e38b87bf7bedffddfc7ff7d578be398456c6c6cbce13d441cc7b5da02fcf4e8e99bde7a8f899b501515d959f64e10e71cd949c6e8d508e6cb7cb050fae49727444d87ed08a566dc0cea545a621b96725e62c522f312c4929ff9e7725e6203439282ec0bc72f74150c30c927d89690163f539619a044564973a1980ae54c01c136a1db518a0024808942780dead16a27e7e0ca55949a81668023b242fcd2901c394663072cd408ad75e18b6d43a7076143710aa1b9049ccd326e064a5979e8f0191cfc5878544368af1b24807caa4cfe507ef8aea0bf6dd8b92de7f00bc1562c95e64416e297f216aadcfa3ca43f10da1f8243112286871507fb05c3c7059d568bde96c5885b01af2d6e4a2db10dc8ff128e0fdd39f4cbaf8576dbe170702afcf6b86467bbce57df8680f0d3230767e0e62bdc55c5e53c476742fabbc318437f209886c3cd41d4b0f74049c78ef21476ef5846cf7ded2831848d55f0aa62816caade11adb7ed2fa0f71ce9d8619ac2e627824a45a72b00e413c5a95c0cf63e052bbe2014bfa738c3de3d251dfb0f8a80fda04e6480600113cc558a11a0e10b93a9225886cff04a8d10868662eab87f37271e59f2136f85a855bfda15f9594eb7a3b4ae0b933f95e161c5ceed88f254e97f2ad49b75eedf8562e2d8fb264355314da1dbada866abe47fedb106d01f78b71fec170c8f7276ef58da3de8f64a76bf6f634283730e9d2b9b8390ce0dae565c6a8e04b0710b746678f8a8e0e18382d173a1d7151c909fe4e84ccf57be3e76245b115143584ee73f27afc8e80b4c667e4c37b7054c8be1afde0de978a9c63485fea0457cec70aa089015ab9297e0938c240573cdb7651a4a7f20f43feb304a72aac2e73bd723da1fe5746ec0682bc26070f38c345905d7e238f6077c00dd8f85280211fcd91af84b02ef94a50c004502c1394813252f14575ca09839242f9484cb42df31e763edd237ff31d6c0ffa3fe17f0fb86c7715cfb1ba8bd86cc8d2decd30000000049454e44ae426082</data> + </image> +</images> +<connections> + <connection> + <sender>chkCustomClientID</sender> + <signal>toggled(bool)</signal> + <receiver>mClientID</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>chkCustomClientID</sender> + <signal>toggled(bool)</signal> + <receiver>mClientVersionMajor</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>chkCustomClientID</sender> + <signal>toggled(bool)</signal> + <receiver>mClientVersionMinor</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>chkCustomClientID</sender> + <signal>toggled(bool)</signal> + <receiver>lblClientIdentifier</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>chkCustomClientID</sender> + <signal>toggled(bool)</signal> + <receiver>lblClientVersion</receiver> + <slot>setEnabled(bool)</slot> + </connection> +</connections> +<tabstops> + <tabstop>mScreenName</tabstop> +</tabstops> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>kopetepasswordwidget.h</includehint> +</includehints> +</UI> |