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/winpopup | |
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/winpopup')
31 files changed, 2848 insertions, 0 deletions
diff --git a/kopete/protocols/winpopup/Makefile.am b/kopete/protocols/winpopup/Makefile.am new file mode 100644 index 00000000..24d84fe4 --- /dev/null +++ b/kopete/protocols/winpopup/Makefile.am @@ -0,0 +1,22 @@ +METASOURCES = AUTO +SUBDIRS = ui icons libwinpopup +AM_CPPFLAGS = -I$(srcdir)/ui \ + -I./ui \ + -I$(srcdir)/libwinpopup \ + $(KOPETE_INCLUDES) \ + $(all_includes) + +kde_module_LTLIBRARIES = kopete_wp.la + +noinst_HEADERS = wpprotocol.h wpeditaccount.h wpaccount.h wpuserinfo.h wpcontact.h wpaddcontact.h + +kopete_wp_la_SOURCES = wpprotocol.cpp wpcontact.cpp wpaddcontact.cpp wpeditaccount.cpp wpaccount.cpp wpuserinfo.cpp +kopete_wp_la_LDFLAGS = -module -no-undefined $(KDE_PLUGIN) $(all_libraries) +kopete_wp_la_LIBADD = ../../libkopete/libkopete.la ./ui/libkopetewpui.la \ + ./libwinpopup/libwinpopup.la $(LIB_KIO) + +service_DATA = kopete_wp.desktop +servicedir = $(kde_servicesdir) + +bin_SCRIPTS = winpopup-send.sh winpopup-install.sh + diff --git a/kopete/protocols/winpopup/icons/Makefile.am b/kopete/protocols/winpopup/icons/Makefile.am new file mode 100644 index 00000000..224eb420 --- /dev/null +++ b/kopete/protocols/winpopup/icons/Makefile.am @@ -0,0 +1,3 @@ +kopeteicondir = $(kde_datadir)/kopete/icons +kopeteicon_ICON = AUTO + diff --git a/kopete/protocols/winpopup/icons/cr128-app-wp_protocol.png b/kopete/protocols/winpopup/icons/cr128-app-wp_protocol.png Binary files differnew file mode 100644 index 00000000..5d1e6003 --- /dev/null +++ b/kopete/protocols/winpopup/icons/cr128-app-wp_protocol.png diff --git a/kopete/protocols/winpopup/icons/cr16-action-wp_away.png b/kopete/protocols/winpopup/icons/cr16-action-wp_away.png Binary files differnew file mode 100644 index 00000000..a2f4d5a6 --- /dev/null +++ b/kopete/protocols/winpopup/icons/cr16-action-wp_away.png diff --git a/kopete/protocols/winpopup/icons/cr16-app-wp_protocol.png b/kopete/protocols/winpopup/icons/cr16-app-wp_protocol.png Binary files differnew file mode 100644 index 00000000..3387da90 --- /dev/null +++ b/kopete/protocols/winpopup/icons/cr16-app-wp_protocol.png diff --git a/kopete/protocols/winpopup/icons/cr32-app-wp_protocol.png b/kopete/protocols/winpopup/icons/cr32-app-wp_protocol.png Binary files differnew file mode 100644 index 00000000..476798a0 --- /dev/null +++ b/kopete/protocols/winpopup/icons/cr32-app-wp_protocol.png diff --git a/kopete/protocols/winpopup/icons/cr48-app-wp_protocol.png b/kopete/protocols/winpopup/icons/cr48-app-wp_protocol.png Binary files differnew file mode 100644 index 00000000..9fa4d6c4 --- /dev/null +++ b/kopete/protocols/winpopup/icons/cr48-app-wp_protocol.png diff --git a/kopete/protocols/winpopup/icons/cr64-app-wp_protocol.png b/kopete/protocols/winpopup/icons/cr64-app-wp_protocol.png Binary files differnew file mode 100644 index 00000000..da4998ed --- /dev/null +++ b/kopete/protocols/winpopup/icons/cr64-app-wp_protocol.png diff --git a/kopete/protocols/winpopup/kopete_wp.desktop b/kopete/protocols/winpopup/kopete_wp.desktop new file mode 100644 index 00000000..9280e14e --- /dev/null +++ b/kopete/protocols/winpopup/kopete_wp.desktop @@ -0,0 +1,85 @@ +[Desktop Entry] +Type=Service +X-Kopete-Version=1000900 +Icon=wp_protocol +ServiceTypes=Kopete/Protocol +X-KDE-Library=kopete_wp +X-Kopete-Messaging-Protocol=messaging/winpopup +X-KDE-PluginInfo-Author=Gav Wood +X-KDE-PluginInfo-Email=gav@kde.org +X-KDE-PluginInfo-Name=kopete_wp +X-KDE-PluginInfo-Version=0.8.0 +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=WinPopup +Name[ar]=منبثقWin +Name[bn]=উইন পপ-আপ +Name[ca]=Finestres emergents +Name[eu]=WinPopup plugina +Name[hi]=विन-पॉपअप +Name[lt]=Windows iššokančios žinutės +Name[ne]=विन पपअप +Name[nn]=Vindaugsmeldingar +Name[pt_BR]=Janela de Contexto +Name[zh_CN]=WinPoup +Comment=Protocol to send Windows WinPopup messages +Comment[ar]=البرتوكول سيصدر رسائل Windows المنبثقة +Comment[be]=Пратакол Windows WinPopup +Comment[bg]=Протокол за изпращане на съобщения Windows WinPopup +Comment[bn]=উইন্ডোজ উইন পপ-আপ বার্তা পাঠাতে প্রোটোকল +Comment[br]=Komenad evit kas kemennadoù Windows WinPopup +Comment[bs]=Protokol za slanje Windows WinPopup poruka +Comment[ca]=Protocol per a enviar missatges de finestres emergents de Windows +Comment[cs]=Protokol k odesílání WinPopup zpráv +Comment[cy]=Protocol i anfon negeseuon WinPopup +Comment[da]=Protokol til at sende Windows WinPopup-beskeder +Comment[de]=Protokoll zur Versendung von Windows WinPopup-Nachrichten +Comment[el]=Πρωτόκολλο για αποστολή μηνυμάτων Windows WinPopup +Comment[es]=Protocolo para enviar un mensaje emergente de windows +Comment[et]=Protokoll Windowsi WinPopup sõnumite saatmiseks +Comment[eu]=Windows WinPopup mezuak bidaltzeko protokoloa +Comment[fa]=قرارداد ارسال پیامهای WinPopup ویندوز +Comment[fi]=Yhteyskäytäntö Windows WinPopup-viestien lähettämiseen +Comment[fr]=Protocole pour envoyer des messages WinPopup +Comment[ga]=Prótacal chun teachtaireachtaí Windows WinPopup a sheoladh +Comment[gl]=Protocolo para enviar mensaxes a máquinas Windows mediante o protocolo Winpopup +Comment[he]=תוסף לשליחת מסרי WinPopup +Comment[hi]=विंडोज़ विन-पॉपअप मैसेंजर भेजने का प्रोटोकॉल +Comment[hr]=Protokol za slanje Windows WinPopup poruka +Comment[hu]=Protokoll Windows felbukkanó üzenetek küldéséhez +Comment[is]=Samskiptamáti til að senda Windows WinPopup skeyti +Comment[it]=Protocollo per inviare messaggi Windows WinPopup +Comment[ja]=Windows の WinPopup メッセージを送るプロトコル +Comment[ka]=Windows WinPopup შეტყობინებების გაგზავნის ოქმი +Comment[kk]=Windows WinPopup хабарларды жіберу протоколы +Comment[km]=ពិធីការដើម្បីផ្ញើសារ WinPopup របស់វ៉ីនដូ +Comment[lt]=Protokolas Windows iššokančių žinučių siuntimui +Comment[mk]=Протокол за испраќање на пораки со Windows WinPopup +Comment[nb]=Protokoll for å sende Windows WinPopup -meldinger +Comment[nds]=Protokoll för't Sennen vun Windows-WinPopup-Narichten +Comment[ne]=विन्डोज विन पपअप सन्देश पठाउनुपर्ने प्रोटोकल +Comment[nl]=Protocol voor verzenden van WinPopup-berichten +Comment[nn]=Protokoll for å senda Windows-vindaugsmeldingar +Comment[pl]=Protokół wysyłania komunikatów Windows WinPopup +Comment[pt]=Um protocolo para enviar mensagens de WinPopup do Windows +Comment[pt_BR]=Protocolo para o envio de mensagens de janela do Windows +Comment[ro]=Protocol de trimis mesaje Windows WinPopup +Comment[ru]=Протокол для отправки сообщений Windows WinPopup +Comment[sk]=Protokol pre posielanie správ Windows WinPopup +Comment[sl]=Protokol za pošiljanje sporočil za Windows WinPopup +Comment[sr]=Протокол за слање Windows WinPopup порука +Comment[sr@Latn]=Protokol za slanje Windows WinPopup poruka +Comment[sv]=Protokoll för att skicka Windows WinPopup-meddelanden +Comment[ta]=விண்டோஸ் தோன்றும் சாளர செய்தியை அனுப்புவதற்கான நெறிமுறை +Comment[tg]=Қарордод барои фиристодани Windows WinPopup пайёмҳо +Comment[tr]=Windows WinPopup mesajları gönderme iletişim kuralı +Comment[uk]=Протокол для відсилання повідомлень WinPopup +Comment[uz]=Windows WinPopup xabarlarni joʻnatish uchun protokol +Comment[uz@cyrillic]=Windows WinPopup хабарларни жўнатиш учун протокол +Comment[wa]=Protocole po les messaedjes WinPopup di Windows +Comment[zh_CN]=发送 Windows WinPopup 信息的协议 +Comment[zh_HK]=用來發送 Windows WinPopup 訊息的通訊協定 +Comment[zh_TW]=送出 WinPopup 訊息的協定 diff --git a/kopete/protocols/winpopup/libwinpopup/Makefile.am b/kopete/protocols/winpopup/libwinpopup/Makefile.am new file mode 100644 index 00000000..e9c5836e --- /dev/null +++ b/kopete/protocols/winpopup/libwinpopup/Makefile.am @@ -0,0 +1,9 @@ +METASOURCES = AUTO + +noinst_LTLIBRARIES = libwinpopup.la +AM_CPPFLAGS = $(KOPETE_INCLUDES) \ + -I$(srcdir)/..\ + $(all_includes) + +libwinpopup_la_SOURCES = libwinpopup.cpp + diff --git a/kopete/protocols/winpopup/libwinpopup/libwinpopup.cpp b/kopete/protocols/winpopup/libwinpopup/libwinpopup.cpp new file mode 100644 index 00000000..d26e461c --- /dev/null +++ b/kopete/protocols/winpopup/libwinpopup/libwinpopup.cpp @@ -0,0 +1,363 @@ +/*************************************************************************** + libwinpopup.cpp - WP Library + ------------------- + begin : Fri Apr 26 2002 + copyright : (C) 2002 by Gav Wood + email : gav@kde.org + *************************************************************************** + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +// QT Includes +#include <qdir.h> +#include <qfileinfo.h> +#include <qregexp.h> + +// KDE Includes +#include <kapplication.h> +#include <kdebug.h> +#include <kmessagebox.h> +#include <klocale.h> +#include <kdirlister.h> + +// Kopete Includes +#include "kopeteuiglobal.h" + +// Local Includes +#include "libwinpopup.h" + +WinPopupLib::WinPopupLib(const QString &smbClient,int groupFreq) + : smbClientBin(smbClient), groupCheckFreq(groupFreq) +{ + connect(&updateGroupDataTimer, SIGNAL(timeout()), this, SLOT(slotUpdateGroupData())); + + updateGroupDataTimer.start(1, true); + QTimer::singleShot(1, this, SLOT(slotStartDirLister())); +} + +WinPopupLib::~WinPopupLib() +{ +} + +void WinPopupLib::slotStartDirLister() +{ + if (checkMessageDir()) { + dirLister = new KDirLister(); + dirLister->setAutoUpdate(true); + connect(dirLister, SIGNAL(newItems(const KFileItemList &)), this, SLOT(slotNewMessages(const KFileItemList &))); + connect(dirLister, SIGNAL(completed()), this, SLOT(slotListCompleted())); + dirLister->openURL(KURL::fromPathOrURL(WP_POPUP_DIR)); + } +} + +/** + * return the group list + */ +const QStringList WinPopupLib::getGroups() +{ + QStringList ret; + QMap<QString, WorkGroup>::ConstIterator end = theGroups.end(); + for(QMap<QString, WorkGroup>::ConstIterator i = theGroups.begin(); i != end; i++) + ret += i.key(); + + return ret; +} + +/** + * return the host list + */ +const QStringList WinPopupLib::getHosts(const QString &Group) +{ + return theGroups[Group].Hosts(); +} + +/** + * return if a host is in the host list + */ +bool WinPopupLib::checkHost(const QString &Name) +{ +// kdDebug() << "WP checkHost: " << Name << endl; + bool ret = false; + + QMap<QString, WorkGroup>::Iterator end = theGroups.end(); + for(QMap<QString, WorkGroup>::Iterator i = theGroups.begin(); i != end && !ret; i++) { + if ((*i).Hosts().contains(Name.upper())) { + ret = true; + break; + } + } + + return ret; +} + + +bool WinPopupLib::checkMessageDir() +{ + QDir dir(WP_POPUP_DIR); + if (! dir.exists()) { + int tmpYesNo = KMessageBox::warningYesNo(Kopete::UI::Global::mainWidget(), + i18n("Working directory %1 does not exist.\n" + "If you have not configured anything yet (samba) please see\n" + "Install Into Samba (Configure... -> Account -> Edit) information\n" + "on how to do this.\n" + "Should the directory be created? (May need root password)").arg(WP_POPUP_DIR), + QString::fromLatin1("Winpopup"), i18n("Create Directory"), i18n("Do Not Create")); + if (tmpYesNo == KMessageBox::Yes) { + QStringList kdesuArgs = QStringList(QString("-c mkdir -p -m 0777 " + WP_POPUP_DIR)); + if (KApplication::kdeinitExecWait("kdesu", kdesuArgs) == 0) return true; + } + } else { + KFileItem tmpFileItem = KFileItem(KFileItem::Unknown, KFileItem::Unknown, KURL::fromPathOrURL(WP_POPUP_DIR)); + mode_t tmpPerms = tmpFileItem.permissions(); + + if (tmpPerms != 0777) { + + kdDebug(14170) << "Perms not ok!" << endl; + + int tmpYesNo = KMessageBox::warningYesNo(Kopete::UI::Global::mainWidget(), + i18n("Permissions of the working directory " + "%1 are wrong!\n" + "You will not receive messages if you say no.\n" + "You can also correct it manually (chmod 0777 %1) and restart kopete.\n" + "Fix? (May need root password)").arg(WP_POPUP_DIR), + QString::fromLatin1("Winpopup"), i18n("Fix"), i18n("Do Not Fix")); + if (tmpYesNo == KMessageBox::Yes) { + QStringList kdesuArgs = QStringList(QString("-c chmod 0777 " + WP_POPUP_DIR)); + if (KApplication::kdeinitExecWait("kdesu", kdesuArgs) == 0) return true; + } + } else { + return true; + } + } + + return false; +} + +/** + * read the groups and their hosts + */ +void WinPopupLib::slotUpdateGroupData() +{ + passedInitialHost = false; + todo.clear(); + currentGroupsMap.clear(); + currentHost = QString::fromLatin1("LOCALHOST"); + startReadProcess(currentHost); +} + +void WinPopupLib::startReadProcess(const QString &Host) +{ + currentHosts.clear(); + currentGroups.clear(); + currentGroup = QString(); + + // for Samba 3 + KProcIO *reader = new KProcIO; + *reader << smbClientBin << "-N" << "-E" << "-g" << "-L" << Host << "-"; + + connect(reader, SIGNAL(readReady(KProcIO *)), this, SLOT(slotReadProcessReady(KProcIO *))); + connect(reader, SIGNAL(processExited(KProcess *)), this, SLOT(slotReadProcessExited(KProcess *))); + + if (!reader->start(KProcess::NotifyOnExit, true)) { + // still to come + kdDebug(14170) << "ReadProcess not started!" << endl; + } +} + +void WinPopupLib::slotReadProcessReady(KProcIO *r) +{ + QString tmpLine = QString::null; + QRegExp group("^Workgroup\\|(.*)\\|(.*)$"), host("^Server\\|(.*)\\|(.*)$"), + info("^Domain=\\[([^\\]]+)\\] OS=\\[([^\\]]+)\\] Server=\\[([^\\]]+)\\]"), + error("Connection.*failed"); + + while (r->readln(tmpLine) > -1) { + if (info.search(tmpLine) != -1) currentGroup = info.cap(1); + if (host.search(tmpLine) != -1) currentHosts += host.cap(1); + if (group.search(tmpLine) != -1) currentGroups[group.cap(1)] = group.cap(2); + if (error.search(tmpLine) != -1) { + kdDebug(14170) << "Connection to " << currentHost << " failed!" << endl; + if (currentHost == QString::fromLatin1("LOCALHOST")) currentHost = QString::fromLatin1("failed"); // to be sure + } + } +} + +void WinPopupLib::slotReadProcessExited(KProcess *r) +{ + delete r; + + // Drop the first cycle - it's only the initial search host, + // the next round are the real masters. GF + + if (passedInitialHost) { + + // move currentHost from todo to done + todo.remove(currentHost); + done += currentHost; + + if (!currentGroups.isEmpty()) { + QMap<QString, WorkGroup> newGroups; + //loop through the read groups and check for new ones + QMap<QString, QString>::ConstIterator end = currentGroups.end(); + for (QMap<QString, QString>::ConstIterator i = currentGroups.begin(); i != end; i++) { + QString groupMaster = i.data(); + if (!done.contains(groupMaster)) todo += groupMaster; + } + } + + if (!currentGroup.isEmpty() && !currentHosts.isEmpty()) { + // create a workgroup object and put the hosts in + WorkGroup nWG; + nWG.addHosts(currentHosts); + + currentGroupsMap.insert(currentGroup, nWG, true); + } + + } else { + passedInitialHost = true; + if (!currentGroups.isEmpty()) { + QMap<QString, QString>::ConstIterator end = currentGroups.end(); + for (QMap<QString, QString>::ConstIterator i = currentGroups.begin(); i != end; i++) { + QString groupMaster = i.data(); + todo += groupMaster; + } + } else { + if (currentHost == QString::fromLatin1("failed")) + KMessageBox::error(Kopete::UI::Global::mainWidget(), + i18n("Connection to localhost failed!\n" + "Is your samba server running?"), + QString::fromLatin1("Winpopup")); + } + } + + // maybe restart cycle + if (todo.count()) { + currentHost = todo[0]; + startReadProcess(currentHost); + } else { + theGroups = currentGroupsMap; + updateGroupDataTimer.start(groupCheckFreq * 1000, true); + } +} + +void WinPopupLib::slotListCompleted() +{ + /// only to check received messages during start up, then we use newItems. GF + disconnect(dirLister, SIGNAL(completed()), this, SLOT(slotListCompleted())); + readMessages(dirLister->items()); +} + +void WinPopupLib::slotNewMessages(const KFileItemList &items) +{ + readMessages(items); +} + +/** + * read new arrived messages + */ +void WinPopupLib::readMessages(const KFileItemList &items) +{ + QPtrListIterator<KFileItem> it(items); + KFileItem *tmpItem; + while ((tmpItem = it.current()) != 0) { + if (tmpItem->isFile()) { + QFile messageFile(tmpItem->url().path()); + + if (messageFile.open(IO_ReadOnly)) { + QTextStream stream(&messageFile); + QString sender; + QDateTime time; + QString text; + + // first line is sender, can this really be empty? GF + sender = stream.readLine(); + sender = sender.upper(); + + // second line is time + QString tmpTime = stream.readLine(); + time = QDateTime::fromString(tmpTime, Qt::ISODate); + + while (!stream.atEnd()) { + text.append(stream.readLine()); + text.append('\n'); + } + + // remove trailing CR + text = text.stripWhiteSpace(); + + messageFile.close(); + + // delete file + if (!messageFile.remove()) { + // QFile::remove() seems to be very persistent, it removes even files with 0444 owned by root + // if the directory permissions are 0777 - so this is just for safety. GF + kdDebug(14170) << "Message file not removed - how that?" << endl; + int tmpYesNo = KMessageBox::warningYesNo(Kopete::UI::Global::mainWidget(), + i18n("A message file could not be removed; " + "maybe the permissions are wrong.\n" + "Fix? (May need root password)"), + QString::fromLatin1("Winpopup"), i18n("Fix"), i18n("Do Not Fix")); + if (tmpYesNo == KMessageBox::Yes) { + QStringList kdesuArgs = QStringList(QString("-c chmod 0666 " + tmpItem->url().path())); + if (KApplication::kdeinitExecWait("kdesu", kdesuArgs) == 0) { + if (!messageFile.remove()) + KMessageBox::error(Kopete::UI::Global::mainWidget(), i18n("Still cannot remove it; please fix manually.")); + } + } + } + if (!sender.isEmpty() && time.isValid()) + emit signalNewMessage(text, time, sender); + else + kdDebug(14170) << "Received invalid message!" << endl; + } + } // isFile + ++it; + } // while +} + +/** + * send a message + */ +void WinPopupLib::sendMessage(const QString &Body, const QString &Destination) +{ + KProcess *sender = new KProcess(this); + *sender << smbClientBin << "-M" << Destination; + *sender << "-N" << "-"; + + connect(sender, SIGNAL(processExited(KProcess *)), this, SLOT(slotSendProcessExited(KProcess *))); + + if (sender->start(KProcess::NotifyOnExit, KProcess::Stdin)) { + sender->writeStdin(Body.local8Bit(), Body.local8Bit().length()); + if (!sender->closeStdin()) { + delete sender; + } + } else { + delete sender; + } +} + +void WinPopupLib::slotSendProcessExited(KProcess *p) +{ +// emit sendJobDone(p->pid()); + delete p; +} + +void WinPopupLib::settingsChanged(const QString &smbClient, int groupFreq) +{ + smbClientBin = smbClient; + groupCheckFreq = groupFreq; + + if (updateGroupDataTimer.isActive()) updateGroupDataTimer.changeInterval(groupCheckFreq * 1000); +} + +#include "libwinpopup.moc" + +// vim: set noet ts=4 sts=4 sw=4: +// kate: tab-width 4; indent-width 4; replace-trailing-space-save on; diff --git a/kopete/protocols/winpopup/libwinpopup/libwinpopup.h b/kopete/protocols/winpopup/libwinpopup/libwinpopup.h new file mode 100644 index 00000000..77f8b8a6 --- /dev/null +++ b/kopete/protocols/winpopup/libwinpopup/libwinpopup.h @@ -0,0 +1,92 @@ +/*************************************************************************** + libwinpopup.h - Base class for the WinPopup protocol + ------------------- + begin : Fri Apr 26 2002 + copyright : (C) 2002 by Gav Wood + email : gav@kde.org + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef LIBWINPOPUP_H +#define LIBWINPOPUP_H + +//QT includes +#include <qobject.h> +#include <qmap.h> +#include <qstringlist.h> +#include <qtimer.h> +#include <qdatetime.h> + +// KDE Includes +#include <kprocio.h> +#include <kfileitem.h> + +const QString WP_POPUP_DIR = QString::fromLatin1("/var/lib/winpopup"); + +class KDirLister; + +typedef QMap<QString, QString> stringMap; + +class WorkGroup +{ + QStringList groupHosts; + +public: + const QStringList &Hosts() { return groupHosts; } + void addHosts(const QStringList &newHosts) { groupHosts = newHosts; } +}; + +class WinPopupLib : public QObject +{ + Q_OBJECT + +public: + WinPopupLib(const QString &smbClient,int groupFreq); + ~WinPopupLib(); + + const QStringList getGroups(); + const QStringList getHosts(const QString &Group); + bool checkHost(const QString &Name); + void settingsChanged(const QString &smbClient, int groupFreq); + void sendMessage(const QString &Body, const QString &Destination); + +private: + bool passedInitialHost; + QMap<QString, WorkGroup> theGroups, currentGroupsMap; + QString currentGroup, currentHost; + QStringList todo, done, currentHosts; + stringMap currentGroups; + QTimer updateGroupDataTimer; + QString smbClientBin; + int groupCheckFreq; + KDirLister *dirLister; + + void readMessages(const KFileItemList &items); + bool checkMessageDir(); + +private slots: + void slotUpdateGroupData(); + void startReadProcess(const QString &Host); + void slotReadProcessReady(KProcIO *r); + void slotReadProcessExited(KProcess *r); + void slotSendProcessExited(KProcess *p); + void slotStartDirLister(); + void slotListCompleted(); + void slotNewMessages(const KFileItemList &items); + +signals: + void signalNewMessage(const QString &, const QDateTime &, const QString &); +}; + +#endif + +// vim: set noet ts=4 sts=4 sw=4: +// kate: tab-width 4; indent-width 4; replace-trailing-space-save on; diff --git a/kopete/protocols/winpopup/ui/Makefile.am b/kopete/protocols/winpopup/ui/Makefile.am new file mode 100644 index 00000000..11d8a7bc --- /dev/null +++ b/kopete/protocols/winpopup/ui/Makefile.am @@ -0,0 +1,10 @@ +METASOURCES = AUTO + +noinst_LTLIBRARIES = libkopetewpui.la +AM_CPPFLAGS = $(KOPETE_INCLUDES) \ + -I$(srcdir)/.. \ + $(all_includes) + + +libkopetewpui_la_SOURCES = wpaddcontactbase.ui wpeditaccountbase.ui empty.cpp wpuserinfowidget.ui +EXTRA_DIST = wpaddcontactbase.ui wpeditaccountbase.ui diff --git a/kopete/protocols/winpopup/ui/empty.cpp b/kopete/protocols/winpopup/ui/empty.cpp new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/kopete/protocols/winpopup/ui/empty.cpp @@ -0,0 +1 @@ + diff --git a/kopete/protocols/winpopup/ui/wpaddcontactbase.ui b/kopete/protocols/winpopup/ui/wpaddcontactbase.ui new file mode 100644 index 00000000..21286d54 --- /dev/null +++ b/kopete/protocols/winpopup/ui/wpaddcontactbase.ui @@ -0,0 +1,190 @@ +<!DOCTYPE UI><UI version="3.1" stdsetdef="1"> +<class>WPAddContactBase</class> +<widget class="QWidget"> + <property name="name"> + <cstring>WPAddContactBase</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>396</width> + <height>342</height> + </rect> + </property> + <property name="font"> + <font> + </font> + </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>layout59</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout57</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>TextLabel2_2</cstring> + </property> + <property name="text"> + <string>Com&puter hostname:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>mHostName</cstring> + </property> + <property name="toolTip" stdset="0"> + <string>The hostname you would like to use to send WinPopup messages to.</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The hostname you would like to use to send WinPopup messages to.</string> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>TextLabel1_2</cstring> + </property> + <property name="text"> + <string>&Workgroup/domain:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>mHostGroup</cstring> + </property> + <property name="toolTip" stdset="0"> + <string>The workgroup or domain the computer is on that you would like to use to send WinPopup messages to.</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The workgroup or domain the computer is on that you would like to use to send WinPopup messages to.</string> + </property> + </widget> + </vbox> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout58</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KComboBox"> + <property name="name"> + <cstring>mHostName</cstring> + </property> + <property name="editable"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>The hostname you would like to use to send WinPopup messages to.</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The hostname you would like to use to send WinPopup messages to.</string> + </property> + </widget> + <widget class="KComboBox"> + <property name="name"> + <cstring>mHostGroup</cstring> + </property> + <property name="toolTip" stdset="0"> + <string>The workgroup or domain the computer is on that you would like to use to send WinPopup messages to.</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The workgroup or domain the computer is on that you would like to use to send WinPopup messages to.</string> + </property> + </widget> + </vbox> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout11</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <spacer> + <property name="name"> + <cstring>Spacer2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="KPushButton"> + <property name="name"> + <cstring>mRefresh</cstring> + </property> + <property name="text"> + <string>&Refresh</string> + </property> + <property name="toolTip" stdset="0"> + <string>Refresh the list of available workgroups & domains on the Windows network.</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Refresh the list of available workgroups & domains on the Windows network.</string> + </property> + </widget> + </hbox> + </widget> + <spacer> + <property name="name"> + <cstring>Spacer4</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>50</height> + </size> + </property> + </spacer> + </vbox> +</widget> +<tabstops> + <tabstop>mHostName</tabstop> + <tabstop>mHostGroup</tabstop> + <tabstop>mRefresh</tabstop> +</tabstops> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>kcombobox.h</includehint> + <includehint>klineedit.h</includehint> + <includehint>kcombobox.h</includehint> + <includehint>kpushbutton.h</includehint> +</includehints> +</UI> diff --git a/kopete/protocols/winpopup/ui/wpeditaccountbase.ui b/kopete/protocols/winpopup/ui/wpeditaccountbase.ui new file mode 100644 index 00000000..464c426d --- /dev/null +++ b/kopete/protocols/winpopup/ui/wpeditaccountbase.ui @@ -0,0 +1,358 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>WPEditAccountBase</class> +<widget class="QWidget"> + <property name="name"> + <cstring>WPEditAccountBase</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>398</width> + <height>445</height> + </rect> + </property> + <property name="caption"> + <string>Account Preferences - WinPopup</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>0</number> + </property> + <widget class="QLabel" row="0" column="1"> + <property name="name"> + <cstring>labelStatusMessage</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="alignment"> + <set>AlignCenter</set> + </property> + </widget> + <widget class="QTabWidget" row="0" column="0"> + <property name="name"> + <cstring>tabWidget10</cstring> + </property> + <widget class="QWidget"> + <property name="name"> + <cstring>tab</cstring> + </property> + <attribute name="title"> + <string>Basi&c Setup</string> + </attribute> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QGroupBox"> + <property name="name"> + <cstring>groupBox51</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>layout40</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>label1</cstring> + </property> + <property name="text"> + <string>Hos&tname:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>mHostName</cstring> + </property> + <property name="toolTip" stdset="0"> + <string>The hostname you would like to use to send WinPopup messages as.</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The hostname you would like to use to send WinPopup messages as. Note that this does not have to be the actual hostname of the machine to send messages, but it does to receive them.</string> + </property> + </widget> + <widget class="QLineEdit"> + <property name="name"> + <cstring>mHostName</cstring> + </property> + <property name="toolTip" stdset="0"> + <string>The hostname you would like to use to send WinPopup messages as.</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The hostname you would like to use to send WinPopup messages as. Note that this does not have to be the actual hostname of the machine to send messages, but it does to receive them.</string> + </property> + </widget> + <widget class="KPushButton"> + <property name="name"> + <cstring>doInstallSamba</cstring> + </property> + <property name="text"> + <string>I&nstall Into Samba</string> + </property> + <property name="toolTip" stdset="0"> + <string>Install support into Samba to enable this service.</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Install support into Samba to enable this service.</string> + </property> + </widget> + </hbox> + </widget> + </vbox> + </widget> + <widget class="QGroupBox"> + <property name="name"> + <cstring>groupBox22</cstring> + </property> + <property name="title"> + <string>Information</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel12</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>To receive WinPopup messages sent from other machines, the hostname above must be set to this machine's hostname.</string> + </property> + <property name="alignment"> + <set>WordBreak|AlignTop</set> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel1_3</cstring> + </property> + <property name="text"> + <string>The samba server must be configured and running.</string> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel1_2</cstring> + </property> + <property name="text"> + <string>"Install into Samba" is a simple method to create the directory for the temporary message files and configure your samba server.<br> +However, the recommended way is to ask your administrator to create this directory ('mkdir -p -m 0777 /var/lib/winpopup') and add +'message command = _PATH_TO_/winpopup-send.sh %s %m %t &' (substitute _PATH_TO_ by the real path) to your smb.conf [global]-section.</string> + </property> + <property name="alignment"> + <set>WordBreak|AlignTop</set> + </property> + </widget> + </vbox> + </widget> + <spacer> + <property name="name"> + <cstring>spacer7</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>21</width> + <height>16</height> + </size> + </property> + </spacer> + </vbox> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>TabPage</cstring> + </property> + <attribute name="title"> + <string>S&ystem</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <spacer row="2" column="0"> + <property name="name"> + <cstring>spacer4</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>135</height> + </size> + </property> + </spacer> + <widget class="QGroupBox" row="1" column="0"> + <property name="name"> + <cstring>groupBox5</cstring> + </property> + <property name="title"> + <string>Information</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="1" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>textLabel2_2</cstring> + </property> + <property name="text"> + <string><i>These options apply to all WinPopup accounts.</i></string> + </property> + </widget> + </grid> + </widget> + <widget class="QGroupBox" row="0" column="0"> + <property name="name"> + <cstring>groupBox4</cstring> + </property> + <property name="title"> + <string>Protocol Preferences</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel4</cstring> + </property> + <property name="text"> + <string>Host check frequency:</string> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="text"> + <string>Path to 'smbclient' executable:</string> + </property> + </widget> + <widget class="QLayoutWidget" row="0" column="1" rowspan="2" colspan="1"> + <property name="name"> + <cstring>layout6</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout5</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KIntSpinBox"> + <property name="name"> + <cstring>mHostCheckFreq</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maxValue"> + <number>3600</number> + </property> + <property name="minValue"> + <number>1</number> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel6</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>3</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>second(s)</string> + </property> + </widget> + </hbox> + </widget> + <widget class="KURLRequester"> + <property name="name"> + <cstring>mSmbcPath</cstring> + </property> + </widget> + </vbox> + </widget> + </grid> + </widget> + </grid> + </widget> + </widget> + </grid> +</widget> +<connections> + <connection> + <sender>doInstallSamba</sender> + <signal>clicked()</signal> + <receiver>WPEditAccountBase</receiver> + <slot>installSamba()</slot> + </connection> +</connections> +<tabstops> + <tabstop>tabWidget10</tabstop> + <tabstop>mHostName</tabstop> + <tabstop>doInstallSamba</tabstop> +</tabstops> +<slots> + <slot>installSamba()</slot> +</slots> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>kpushbutton.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>kurlrequester.h</includehint> + <includehint>klineedit.h</includehint> + <includehint>kpushbutton.h</includehint> +</includehints> +</UI> diff --git a/kopete/protocols/winpopup/ui/wpuserinfowidget.ui b/kopete/protocols/winpopup/ui/wpuserinfowidget.ui new file mode 100644 index 00000000..a899e3ca --- /dev/null +++ b/kopete/protocols/winpopup/ui/wpuserinfowidget.ui @@ -0,0 +1,219 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>WPUserInfoWidget</class> +<widget class="QWidget"> + <property name="name"> + <cstring>WPUserInfoWidget</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>402</width> + <height>175</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget" row="0" column="0"> + <property name="name"> + <cstring>layout6</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout5</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>lblComputerName</cstring> + </property> + <property name="text"> + <string>&Computer name:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>sComputerName</cstring> + </property> + <property name="toolTip" stdset="0"> + <string>The hostname of the computer for this contact.</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The hostname of the computer for this contact.</string> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel2_2</cstring> + </property> + <property name="text"> + <string>Comment:</string> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel2</cstring> + </property> + <property name="text"> + <string>&Workgroup/domain:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>sWorkgroup</cstring> + </property> + <property name="toolTip" stdset="0"> + <string>The workgroup or domain the contact's computer is on.</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The workgroup or domain the contact's computer is on.</string> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel3</cstring> + </property> + <property name="text"> + <string>Operating s&ystem:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>sOS</cstring> + </property> + <property name="toolTip" stdset="0"> + <string>The operating system the contact's computer is running.</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The operating system the contact's computer is running.</string> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="text"> + <string>Ser&ver software:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>sServer</cstring> + </property> + <property name="toolTip" stdset="0"> + <string>The software the contact's computer is running.</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The software the contact's computer is running.</string> + </property> + </widget> + </vbox> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout4</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KLineEdit"> + <property name="name"> + <cstring>sComputerName</cstring> + </property> + <property name="readOnly"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>The hostname of the computer for this contact.</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The hostname of the computer for this contact.</string> + </property> + </widget> + <widget class="KLineEdit"> + <property name="name"> + <cstring>sComment</cstring> + </property> + <property name="readOnly"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>The comment of the computer for this contact.</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The comment of the computer for this contact.</string> + </property> + </widget> + <widget class="KLineEdit"> + <property name="name"> + <cstring>sWorkgroup</cstring> + </property> + <property name="readOnly"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>The workgroup or domain the contact's computer is on.</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The workgroup or domain the contact's computer is on.</string> + </property> + </widget> + <widget class="KLineEdit"> + <property name="name"> + <cstring>sOS</cstring> + </property> + <property name="readOnly"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>The operating system the contact's computer is running.</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The operating system the contact's computer is running.</string> + </property> + </widget> + <widget class="KLineEdit"> + <property name="name"> + <cstring>sServer</cstring> + </property> + <property name="readOnly"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>The software the contact's computer is running.</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The software the contact's computer is running.</string> + </property> + </widget> + </vbox> + </widget> + </hbox> + </widget> + </grid> +</widget> +<tabstops> + <tabstop>sComputerName</tabstop> + <tabstop>sWorkgroup</tabstop> + <tabstop>sOS</tabstop> + <tabstop>sServer</tabstop> +</tabstops> +<layoutdefaults spacing="6" margin="0"/> +<includehints> + <includehint>klineedit.h</includehint> + <includehint>klineedit.h</includehint> + <includehint>klineedit.h</includehint> + <includehint>klineedit.h</includehint> + <includehint>klineedit.h</includehint> +</includehints> +</UI> diff --git a/kopete/protocols/winpopup/winpopup-install.sh b/kopete/protocols/winpopup/winpopup-install.sh new file mode 100755 index 00000000..3106b064 --- /dev/null +++ b/kopete/protocols/winpopup/winpopup-install.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +PATH=/bin:/usr/bin + +# Grab the full path to the smb.conf file +i=`find /etc -name smb.conf` + +# Create new smb.conf file with updated message command line +echo "[global]" > ~/smb.conf.new +echo " message command = $1 %s %m %t &" >> ~/smb.conf.new +cat $i | grep -v "message command = " | grep -v "\[global\]" >> ~/smb.conf.new + +# Backup the old file +mv -f $i "$i.old" + +# Move new file into place and reset permissions +mv -f ~/smb.conf.new $i +chown root:root $i +chmod 644 $i + +# Create a winpopup directory somewhere "safe" +#rm -rf /var/lib/winpopup --- a bit strong? +if [ ! -d /var/lib/winpopup ]; then + mkdir -p /var/lib/winpopup +fi + +chmod 0777 /var/lib/winpopup + +# This is to help if somebody grades up from the old behavior +if [ -n "`ls -A /var/lib/winpopup/`" ]; then + chmod 666 /var/lib/winpopup/* +fi + +rm -f /var/lib/winpopup/message + +# Force Samba to reread configuration +killall -HUP smbd diff --git a/kopete/protocols/winpopup/winpopup-send.sh b/kopete/protocols/winpopup/winpopup-send.sh new file mode 100755 index 00000000..9a80b20b --- /dev/null +++ b/kopete/protocols/winpopup/winpopup-send.sh @@ -0,0 +1,44 @@ +#!/bin/sh +PATH=/bin:/usr/bin/:/usr/local/bin + +# Check input +[ -z "$1" -o -z "$2" ] && exit 1 + +# Check if file is indeed a file and readable +[ ! -f "$1" -o ! -r "$1" ] && exit 1 + +KOPETE_RUNNING=x`ps -A|grep -e "kopete$"` + +if [ "$KOPETE_RUNNING" = "x" ]; then + + if [ -z "$3" ]; then + THIS_SERVER=`uname -n` + else + THIS_SERVER="$3" + fi + + if [ "$2" != "$THIS_SERVER" ]; then + echo -e "Kopete is currently not running.\nYour message was not delivered!" \ + | smbclient -N -M $2 + fi + +else + + # Create a unique filename + filename="/var/lib/winpopup/`date +%s_%N`" + + # the time... + TIME=`date --iso-8601=seconds` + + # the message + MESSAGE=`cat "$1"` + + # Put it into the file + echo -e "$2\n$TIME\n$MESSAGE" > $filename + + +fi + +# Remove the message from samba +rm -f "$1" + diff --git a/kopete/protocols/winpopup/wpaccount.cpp b/kopete/protocols/winpopup/wpaccount.cpp new file mode 100644 index 00000000..4b1342ff --- /dev/null +++ b/kopete/protocols/winpopup/wpaccount.cpp @@ -0,0 +1,209 @@ +/*************************************************************************** + wpaccount.cpp - WP Plugin + ------------------- + begin : Fri Apr 26 2002 + copyright : (C) 2002 by Gav Wood + email : gav@indigoarchive.net + + Based on code from : (C) 2002 by Duncan Mac-Vicar Prett + email : duncan@kde.org + *************************************************************************** + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +// QT Includes +#include <qregexp.h> + +// KDE Includes +#include <kdebug.h> +#include <kpopupmenu.h> +#include <klocale.h> +#include <kconfig.h> + +// Kopete Includes + +// Local Includes +#include "wpaccount.h" + +class KPopupMenu; + +WPAccount::WPAccount(WPProtocol *parent, const QString &accountID, const char *name) + : Kopete::Account(parent, accountID, name) +{ +// kdDebug(14170) << "WPAccount::WPAccount()" << endl; + + mProtocol = WPProtocol::protocol(); + + // we need this before initActions + Kopete::MetaContact *myself = Kopete::ContactList::self()->myself(); + setMyself( new WPContact(this, accountID, myself->displayName(), myself) ); + +// if (excludeConnect()) connect(Kopete::OnlineStatus::Online); // ?? +} + +// Destructor +WPAccount::~WPAccount() +{ +} + +const QStringList WPAccount::getGroups() +{ + return mProtocol->getGroups(); +} + +const QStringList WPAccount::getHosts(const QString &Group) +{ + return mProtocol->getHosts(Group); +} + +bool WPAccount::checkHost(const QString &Name) +{ +// kdDebug() << "WPAccount::checkHost: " << Name << endl; + if (Name.upper() == QString::fromLatin1("LOCALHOST")) { + // Assume localhost is always there, but it will not appear in the samba output. + // Should never happen as localhost is now forbidden as contact, just for safety. GF + return true; + } else { + return mProtocol->checkHost(Name); + } +} + +bool WPAccount::createContact(const QString &contactId, Kopete::MetaContact *parentContact ) +{ +// kdDebug(14170) << "[WPAccount::createContact] contactId: " << contactId << endl; + + if (!contacts()[contactId]) { + WPContact *newContact = new WPContact(this, contactId, parentContact->displayName(), parentContact); + return newContact != 0; + } else { + kdDebug(14170) << "[WPAccount::addContact] Contact already exists" << endl; + } + + return false; +} + +void WPAccount::slotGotNewMessage(const QString &Body, const QDateTime &Arrival, const QString &From) +{ +// kdDebug(14170) << "WPAccount::slotGotNewMessage(" << Body << ", " << Arrival.toString() << ", " << From << ")" << endl; + + // Ignore messages from own host or IPs. + // IPs can not be matched to an account anyway. + // This should happen rarely but they make kopete crash. + // The reason for this seems to be in ChatSessionManager? GF + QRegExp ip("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}"); + +// kdDebug(14170) << "ip.search: " << From << " match: " << ip.search(From) << endl; + + if (From == accountId() || ip.exactMatch(From)) { + kdDebug(14170) << "Ignoring message from own host/account or IP." << endl; + return; + } + + if (isConnected()) { + if (!isAway()) { + if(!contacts()[From]) { + addContact(From, From, 0, Kopete::Account::DontChangeKABC); + } + static_cast<WPContact *>(contacts()[From])->slotNewMessage(Body, Arrival); + } + else { + if (!theAwayMessage.isEmpty()) mProtocol->sendMessage(theAwayMessage, From); + } + } else { + // What to do with offline received messages? + kdDebug(14170) << "That's strange - we got a message while offline! Ignoring." << endl; + } +} + +void WPAccount::connect(const Kopete::OnlineStatus &) +{ +// kdDebug(14170) << "WPAccount::Connect()" << endl; + myself()->setOnlineStatus(mProtocol->WPOnline); +} + +void WPAccount::disconnect() +{ +// kdDebug(14170) << "WPAccount::Disconnect()" << endl; + myself()->setOnlineStatus(mProtocol->WPOffline); +} + +/* I commented this code because deleting myself may have *dangerous* side effect, for example, for the status tracking. +void WPAccount::updateAccountId() +{ + delete myself(); + theInterface->setHostName(accountId()); + myself() = new WPContact(this, accountId(), accountId(), 0); +}*/ + +void WPAccount::setAway(bool status, const QString &awayMessage) +{ +// kdDebug(14170) << "WPAccount::setAway()" << endl; + + theAwayMessage = awayMessage; + +// if(!isConnected()) +// theInterface->goOnline(); + myself()->setOnlineStatus(status ? mProtocol->WPAway : mProtocol->WPOnline); +} + +KActionMenu* WPAccount::actionMenu() +{ + kdDebug(14170) << "WPAccount::actionMenu()" << endl; + + /// How to remove an action from Kopete::Account::actionMenu()? GF + + KActionMenu *theActionMenu = new KActionMenu(accountId() , myself()->onlineStatus().iconFor(this), this); + theActionMenu->popupMenu()->insertTitle(myself()->onlineStatus().iconFor(this), i18n("WinPopup (%1)").arg(accountId())); + + if (mProtocol) + { + KAction *goOnline = new KAction("Online", QIconSet(mProtocol->WPOnline.iconFor(this)), 0, + this, SLOT(connect()), theActionMenu, "actionGoAvailable"); + goOnline->setEnabled(isConnected() && isAway()); + theActionMenu->insert(goOnline); + + KAction *goAway = new KAction("Away", QIconSet(mProtocol->WPAway.iconFor(this)), 0, + this, SLOT(goAway()), theActionMenu, "actionGoAway"); + goAway->setEnabled(isConnected() && !isAway()); + theActionMenu->insert(goAway); + + /// One can not really go offline manually - appears online as long as samba server is running. GF + + theActionMenu->popupMenu()->insertSeparator(); + theActionMenu->insert(new KAction(i18n("Properties"), 0, + this, SLOT(editAccount()), theActionMenu, "actionAccountProperties")); + + } + + return theActionMenu; +} + +void WPAccount::slotSendMessage(const QString &Body, const QString &Destination) +{ + kdDebug(14170) << "WPAccount::slotSendMessage(" << Body << ", " << Destination << ")" << endl; + + if (myself()->onlineStatus().status() == Kopete::OnlineStatus::Away) myself()->setOnlineStatus(mProtocol->WPOnline); + mProtocol->sendMessage(Body, Destination); +} + +void WPAccount::setOnlineStatus(const Kopete::OnlineStatus &status, const QString &reason) +{ + if (myself()->onlineStatus().status() == Kopete::OnlineStatus::Offline && status.status() == Kopete::OnlineStatus::Online) + connect( status ); + else if (myself()->onlineStatus().status() != Kopete::OnlineStatus::Offline && status.status() == Kopete::OnlineStatus::Offline) + disconnect(); + else if (myself()->onlineStatus().status() != Kopete::OnlineStatus::Offline && status.status() == Kopete::OnlineStatus::Away) + setAway( true, reason ); +} + +#include "wpaccount.moc" + +// vim: set noet ts=4 sts=4 sw=4: +// kate: tab-width 4; indent-width 4; replace-trailing-space-save on; diff --git a/kopete/protocols/winpopup/wpaccount.h b/kopete/protocols/winpopup/wpaccount.h new file mode 100644 index 00000000..f916ca86 --- /dev/null +++ b/kopete/protocols/winpopup/wpaccount.h @@ -0,0 +1,107 @@ +/*************************************************************************** + wpaccount.h - Base class for the Kopete WP account + ------------------- + begin : Fri Apr 26 2002 + copyright : (C) 2002 by Gav Wood + email : gav@indigoarchive.net + + Based on code from : (C) 2002 by Duncan Mac-Vicar Prett + email : duncan@kde.org + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef WPACCOUNT_H +#define WPACCOUNT_H + + +// QT Includes +#include <qpixmap.h> + +// KDE Includes + +// Kopete Includes +#include "kopetemetacontact.h" +#include "kopeteaccount.h" +#include "kopeteonlinestatus.h" + +// Local Includes +#include "wpcontact.h" +#include "wpaddcontact.h" + +class KPopupMenu; +class KActionMenu; +class KAction; +class WPProtocol; +class KopeteWinPopup; + +/** + * The actual Account class used by Kopete. + */ +class WPAccount : public Kopete::Account +{ + Q_OBJECT + +// Kopete::Account overloading +public: + WPAccount(WPProtocol *parent, const QString& accountID, const char *name = 0); + ~WPAccount(); + + virtual KActionMenu* actionMenu(); // Per-protocol actions for the systray and the status bar + virtual void setAway(bool status, const QString &); // Set user away + +public slots: + virtual void connect(const Kopete::OnlineStatus &); // Connect to server + virtual void disconnect(); // Disconnect from server + + void goAvailable() { setAway(false, QString::null); } // Two convenience slots + void goAway() { setAway(true, QString::null); } // for available and away + +// Stuff used internally & by colleague classes +public: + const QStringList getGroups(); + const QStringList getHosts(const QString &Group); + +// Stuff used by WPContact +public: + /** + * Returns whether or not the named host is online. + */ + bool checkHost(const QString &Name); + +public slots: + /** + * Dispatches said message to the destination. + */ + void slotSendMessage(const QString &Body, const QString &Destination); + + /** + * Called when a new message arrives with the message's data. + */ + void slotGotNewMessage(const QString &Body, const QDateTime &Arrival, const QString &From); + + /* Reimplemented from Kopete::Account */ + void setOnlineStatus( const Kopete::OnlineStatus &status , const QString &reason = QString::null); + +protected: + virtual bool createContact(const QString &contactId, Kopete::MetaContact *parentContact); + +private slots: +// void updateAccountId(); + +private: + WPProtocol *mProtocol; + QString theAwayMessage; // The message to give when the user is away +}; + +#endif + +// vim: set noet ts=4 sts=4 sw=4: +// kate: tab-width 4; indent-width 4; replace-trailing-space-save on; diff --git a/kopete/protocols/winpopup/wpaddcontact.cpp b/kopete/protocols/winpopup/wpaddcontact.cpp new file mode 100644 index 00000000..6187c644 --- /dev/null +++ b/kopete/protocols/winpopup/wpaddcontact.cpp @@ -0,0 +1,115 @@ +/*************************************************************************** + wppreferences.cpp - description + ------------------- + begin : Fri Apr 26 2002 + copyright : (C) 2002 by Gav Wood + email : gav@kde.org + + Based on code from : (C) 2002 by Duncan Mac-Vicar Prett + email : duncan@kde.org + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +// QT Includes +#include <qlayout.h> + +// KDE Includes +#include <kcombobox.h> +#include <kdebug.h> +#include <kiconloader.h> +#include <kurlrequester.h> +#include <kmessagebox.h> +#include <klocale.h> + +// Kopete Includes +#include <addcontactpage.h> + +// Local Includes +#include "wpaddcontactbase.h" +#include "wpaccount.h" +#include "wpaddcontact.h" + +WPAddContact::WPAddContact(QWidget *parent, WPAccount *newAccount, const char *name) : AddContactPage(parent, name) +{ +// kdDebug(14170) << "WPAddContact::WPAddContact(<owner>, " << newAccount << ", <parent>, " << name << ")" << endl; + + (new QVBoxLayout(this))->setAutoAdd(true); + theDialog = new WPAddContactBase(this); + connect(theDialog->mHostGroup, SIGNAL(activated(const QString &)), this, SLOT(slotSelected(const QString &))); + connect(theDialog->mRefresh, SIGNAL(clicked()), this, SLOT(slotUpdateGroups())); + theDialog->show(); + + theAccount = newAccount; + + slotUpdateGroups(); + slotSelected(theDialog->mHostGroup->currentText()); +} + +WPAddContact::~WPAddContact() +{ +} + +void WPAddContact::slotUpdateGroups() +{ + kdDebug(14170) << "WPAddContact::slotUpdateGroups()" << endl; + + theDialog->mHostGroup->clear(); + QStringList Groups = theAccount->getGroups(); + QStringList::ConstIterator end = Groups.end(); + for (QStringList::ConstIterator i = Groups.begin(); i != end; i++) + theDialog->mHostGroup->insertItem(SmallIcon("network"), *i); + slotSelected(theDialog->mHostGroup->currentText()); +} + +void WPAddContact::slotSelected(const QString &Group) +{ + kdDebug(14170) << "WPAddContact::slotSelected(" << Group << ")" << endl; + + theDialog->mHostName->clear(); + QStringList Hosts = theAccount->getHosts(Group); + QString ownHost = theAccount->myself()->contactId(); + QStringList::ConstIterator end = Hosts.end(); + for (QStringList::ConstIterator i = Hosts.begin(); i != end; i++) + if (*i != ownHost) theDialog->mHostName->insertItem(SmallIcon("personal"), *i); +} + +bool WPAddContact::validateData() +{ + kdDebug(14170) << "WPAddContact::validateData()" << endl; + + QString tmpHostName = theDialog->mHostName->currentText(); + + if (tmpHostName.isEmpty()) { + KMessageBox::sorry(this, i18n("<qt>You must enter a valid hostname.</qt>"), i18n("WinPopup")); + return false; + } + + // If our own host is not allowed as contact localhost should be forbidden as well, + // additionally somehow localhost as contact crashes when receiving a message from it?? GF + if (tmpHostName.upper() == QString::fromLatin1("LOCALHOST")) { + KMessageBox::sorry(this, i18n("<qt>LOCALHOST is not allowed as contact.</qt>"), i18n("WinPopup")); + return false; + } + + return true; +} + +bool WPAddContact::apply(Kopete::Account *theAccount, Kopete::MetaContact *theMetaContact) +{ + kdDebug(14170) << "WPAddContact::apply(" << theAccount << ", " << theMetaContact << ")" << endl; + + // TODO: make the nickname an option + return theAccount->addContact(theDialog->mHostName->currentText(), theMetaContact, Kopete::Account::ChangeKABC ); +} + +#include "wpaddcontact.moc" + +// vim: set noet ts=4 sts=4 sw=4: +// kate: tab-width 4; indent-width 4; replace-trailing-space-save on; diff --git a/kopete/protocols/winpopup/wpaddcontact.h b/kopete/protocols/winpopup/wpaddcontact.h new file mode 100644 index 00000000..4d593cba --- /dev/null +++ b/kopete/protocols/winpopup/wpaddcontact.h @@ -0,0 +1,58 @@ +/*************************************************************************** + wpaddcontact.h - description + ------------------- + begin : Wed Jan 23 2002 + copyright : (C) 2002 by Gav Wood + email : gav@kde.org + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef WPADDCONTACT_H +#define WPADDCONTACT_H + +// Kopete Includes +#include <addcontactpage.h> + +// QT Includes + +// KDE Includes + +// Local Includes + +class WPAccount; +class WPAddContactBase; +namespace Kopete { class MetaContact; } + +class WPAddContact: public AddContactPage +{ + Q_OBJECT + +private: + WPAccount *theAccount; + WPAddContactBase *theDialog; + +public: + WPAddContact(QWidget *parent, WPAccount *newAccount, const char *name = 0); + ~WPAddContact(); + + virtual bool validateData(); + +public slots: + virtual bool apply(Kopete::Account *theAccount, Kopete::MetaContact *theMetaContact); + + void slotSelected(const QString &Group); + void slotUpdateGroups(); +}; + +#endif + +// vim: set noet ts=4 sts=4 sw=4: +// kate: tab-width 4; indent-width 4; replace-trailing-space-save on; diff --git a/kopete/protocols/winpopup/wpcontact.cpp b/kopete/protocols/winpopup/wpcontact.cpp new file mode 100644 index 00000000..7cf2529c --- /dev/null +++ b/kopete/protocols/winpopup/wpcontact.cpp @@ -0,0 +1,189 @@ +/*************************************************************************** + wpcontact.cpp - description + ------------------- + begin : Fri Apr 12 2002 + copyright : (C) 2002 by Gav Wood + email : gav@kde.org + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +// Qt Includes +#include <qregexp.h> + +// KDE Includes +#include <kdebug.h> + +// Kopete Includes + +// Local Includes +#include "wpcontact.h" +#include "wpaccount.h" + +WPContact::WPContact(Kopete::Account *account, const QString &newHostName, const QString &nickName, Kopete::MetaContact *metaContact) + : Kopete::Contact(account, newHostName, metaContact) +{ +// kdDebug(14170) << "WPContact::WPContact(<account>, " << newHostName << ", " << nickName << ", <parent>)" << endl; + kdDebug(14170) << "WPContact::WPContact: " << this << endl; + + QString theNickName = nickName; + + if (theNickName.isEmpty()) { + // Construct nickname from hostname with first letter to upper. GF + theNickName = newHostName.lower(); + theNickName = theNickName.replace(0, 1, theNickName[0].upper()); + } + + setNickName(theNickName); + myWasConnected = false; + + + m_manager = 0; + m_infoDialog = 0; + + // Initialise and start the periodical checking for contact's status + setOnlineStatus(static_cast<WPProtocol *>(protocol())->WPOffline); + + connect(&checkStatus, SIGNAL(timeout()), this, SLOT(slotCheckStatus())); + checkStatus.start(1000, false); +} + +QPtrList<KAction> * WPContact::customContextMenuActions() +{ + //myActionCollection = new KActionCollection(parent); + return 0; +} + +void WPContact::serialize(QMap<QString, QString> &serializedData, QMap<QString, QString> &addressBookData) +{ +// kdDebug(14170) << "WP::serialize(...)" << endl; + + Kopete::Contact::serialize(serializedData, addressBookData); +} + +Kopete::ChatSession* WPContact::manager( Kopete::Contact::CanCreateFlags /*canCreate*/ ) // TODO: use the parameter as canCreate +{ + if (m_manager == 0) { + // Set up the message managers + QPtrList<Kopete::Contact> singleContact; + singleContact.append(this); + + m_manager = Kopete::ChatSessionManager::self()->create( account()->myself(), singleContact, protocol() ); + + connect(m_manager, SIGNAL(messageSent(Kopete::Message &, Kopete::ChatSession *)), this, SLOT(slotSendMessage(Kopete::Message &))); + connect(m_manager, SIGNAL(messageSent(Kopete::Message &, Kopete::ChatSession *)), m_manager, SLOT(appendMessage(Kopete::Message &))); + connect(m_manager, SIGNAL(destroyed()), this, SLOT(slotChatSessionDestroyed())); + } + + return m_manager; +} + +/* +bool WPContact::isOnline() const +{ + kdDebug(14170) << "[WPContact::isOnline()]" << endl; + return onlineStatus().status() != Kopete::OnlineStatus::Offline && onlineStatus().status() != Kopete::OnlineStatus::Unknown; +} +*/ + +bool WPContact::isReachable() +{ +// kdDebug(14170) << "[WPContact::isReachable()]" << endl; + return onlineStatus().status() != Kopete::OnlineStatus::Offline && onlineStatus().status() != Kopete::OnlineStatus::Unknown; +} + +void WPContact::slotChatSessionDestroyed() +{ + m_manager = 0; +} + +void WPContact::slotUserInfo() +{ + kdDebug( 14170 ) << k_funcinfo << endl; + + if (!m_infoDialog) { + m_infoDialog = new WPUserInfo( this, static_cast<WPAccount*>( account() ) ); + if (!m_infoDialog) return; + connect( m_infoDialog, SIGNAL( closing() ), this, SLOT( slotCloseUserInfoDialog() ) ); + m_infoDialog->show(); + } else { + m_infoDialog->raise(); + } +} + +void WPContact::slotCloseUserInfoDialog() +{ + m_infoDialog->delayedDestruct(); + m_infoDialog = 0; +} + +/* +void deleteContact() +{ +// deleteLater(); +} +*/ + +void WPContact::slotCheckStatus() +{ + bool oldWasConnected = myWasConnected; + bool newIsOnline = false; + + myWasConnected = protocol() != 0 && account() != 0; + WPAccount *acct = dynamic_cast<WPAccount *>(account()); + if (acct) newIsOnline = acct->checkHost(contactId()); + + if(newIsOnline != isOnline() || myWasConnected != oldWasConnected) { + Kopete::OnlineStatus tmpStatus = WPProtocol::protocol()->WPOffline; + if (myWasConnected && newIsOnline) { + tmpStatus = WPProtocol::protocol()->WPOnline; + } + setOnlineStatus(tmpStatus); + } +} + +void WPContact::slotNewMessage(const QString &Body, const QDateTime &Arrival) +{ + kdDebug(14170) << "WPContact::slotNewMessage(" << Body << ", " << Arrival.toString() << ")" << endl; + + QPtrList<Kopete::Contact> contactList; + contactList.append(account()->myself()); + + QRegExp subj("^Subject: ([^\n]*)\n(.*)$"); + Kopete::Message msg; + + if(subj.search(Body) == -1) { + msg = Kopete::Message(this, contactList, Body, Kopete::Message::Inbound); + } else { + msg = Kopete::Message(this, contactList, subj.cap(2), subj.cap(1), Kopete::Message::Inbound); + } + + manager(Kopete::Contact::CannotCreate)->appendMessage(msg); +} + +void WPContact::slotSendMessage( Kopete::Message& message ) +{ +// kdDebug(14170) << "WPContact::slotSendMessage(<message>)" << endl; + // Warning: this could crash + kdDebug(14170) << message.to().first() << " is " << dynamic_cast<WPContact *>( message.to().first() )->contactId() << endl; + + QString Message = (!message.subject().isEmpty() ? "Subject: " + message.subject() + "\n" : QString("")) + message.plainBody(); + WPAccount *acct = dynamic_cast<WPAccount *>(account()); + WPContact *contact = dynamic_cast<WPContact *>( message.to().first() ); + if (acct && contact) { + acct->slotSendMessage( Message, contact->contactId() ); + m_manager->messageSucceeded(); + } +} + +#include "wpcontact.moc" + +// vim: set noet ts=4 sts=4 sw=4: +// kate: tab-width 4; indent-width 4; replace-trailing-space-save on; diff --git a/kopete/protocols/winpopup/wpcontact.h b/kopete/protocols/winpopup/wpcontact.h new file mode 100644 index 00000000..343e07f7 --- /dev/null +++ b/kopete/protocols/winpopup/wpcontact.h @@ -0,0 +1,86 @@ +/*************************************************************************** + wpcontact.h - description + ------------------- + begin : Fri Apr 12 2002 + copyright : (C) 2002 by Gav Wood + email : gav@indigoarchive.net + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 WPCONTACT_H +#define WPCONTACT_H + +// KDE Includes +#include <kaction.h> + +// Qt Includes +//#include <qvaluestack.h> +#include <qdatetime.h> +#include <qptrlist.h> +#include <qtimer.h> +#include <qstringlist.h> + +// Kopete Includes +#include "kopetecontact.h" +#include "kopetecontactlist.h" +#include "kopetechatsessionmanager.h" +#include "kopetechatsession.h" +#include "kopetemessage.h" + +// Local Includes +#include "wpprotocol.h" +#include "wpuserinfo.h" + +class QTimer; +class QListView; +class QListViewItem; +class KPopupMenu; +class KAction; +namespace Kopete { class MetaContact; } + +class WPContact: public Kopete::Contact +{ + Q_OBJECT + +public: + WPContact(Kopete::Account *account, const QString &userId, const QString &fullName, Kopete::MetaContact *metaContact); + +// virtual bool isOnline() const; + virtual bool isReachable(); + virtual QPtrList<KAction> *customContextMenuActions(); + virtual Kopete::ChatSession *manager(Kopete::Contact::CanCreateFlags = Kopete::Contact::CannotCreate); + virtual void serialize(QMap<QString, QString> &serializedData, QMap<QString, QString> &addressBookData); + +public slots: + virtual void slotUserInfo(); + void slotCheckStatus(); // the call back for the checkStatus timer + void slotNewMessage(const QString &Body, const QDateTime &Arrival); + +private slots: + void slotChatSessionDestroyed(); + void slotSendMessage(Kopete::Message &message); + void slotCloseUserInfoDialog(); // Called when the userinfo dialog is getting closed + +private: + bool myWasConnected; // true if protocol connected at last check + + QTimer checkStatus; // checks the status of this contact every second or so +// KActionCollection *myActionCollection; + // holds all the protocol specific actions (not many!) + Kopete::ChatSession *m_manager; + // holds the two message managers - one for email and one for chat + WPUserInfo *m_infoDialog; +}; + +#endif + +// vim: set noet ts=4 sts=4 sw=4: +// kate: tab-width 4; indent-width 4; replace-trailing-space-save on; diff --git a/kopete/protocols/winpopup/wpeditaccount.cpp b/kopete/protocols/winpopup/wpeditaccount.cpp new file mode 100644 index 00000000..454f5d6f --- /dev/null +++ b/kopete/protocols/winpopup/wpeditaccount.cpp @@ -0,0 +1,138 @@ +/*************************************************************************** + wpeditaccount.cpp - description + ------------------- + begin : Fri Apr 26 2002 + copyright : (C) 2002 by Gav Wood + email : gav@kde.org + + Based on code from : (C) 2002 by Duncan Mac-Vicar Prett + email : duncan@kde.org + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +// Standard Unix Includes +#include <unistd.h> + +// QT Includes +#include <qcheckbox.h> +#include <qfile.h> + +// KDE Includes +#include <kdebug.h> +#include <klocale.h> +#include <kurlrequester.h> +#include <knuminput.h> +#include <klineedit.h> +#include <kmessagebox.h> +#include <kconfig.h> +#include <kapplication.h> +#include <kstandarddirs.h> + + +// Kopete Includes +#include <addcontactpage.h> + +// Local Includes +#include "wpaccount.h" +#include "wpeditaccount.h" +#include "wpprotocol.h" + +WPEditAccount::WPEditAccount(QWidget *parent, Kopete::Account *theAccount) + : WPEditAccountBase(parent), KopeteEditAccountWidget(theAccount) +{ + kdDebug(14170) << "WPEditAccount::WPEditAccount(<parent>, <theAccount>)"; + + mProtocol = WPProtocol::protocol(); + + QString tmpSmbcPath = KStandardDirs::findExe("smbclient"); + + if(account()) { + mHostName->setText(account()->accountId()); +// mAutoConnect->setChecked(account()->excludeConnect()); + mHostName->setReadOnly(true); + KGlobal::config()->setGroup("WinPopup"); + mHostCheckFreq->setValue(KGlobal::config()->readNumEntry("HostCheckFreq", 60)); + mSmbcPath->setURL(KGlobal::config()->readEntry("SmbcPath", tmpSmbcPath)); + + } + else { + // no QT/KDE function? GF + QString theHostName = QString::null; + char *tmp = new char[255]; + + if (tmp != 0) { + gethostname(tmp, 255); + theHostName = tmp; + if (theHostName.contains('.') != 0) theHostName.remove(theHostName.find('.'), theHostName.length()); + theHostName = theHostName.upper(); + } + + if (!theHostName.isEmpty()) + mHostName->setText(theHostName); + else + mHostName->setText("LOCALHOST"); + + mHostCheckFreq->setValue(60); + mSmbcPath->setURL(tmpSmbcPath); + } + + show(); +} + +void WPEditAccount::installSamba() +{ + mProtocol->installSamba(); +} + +bool WPEditAccount::validateData() +{ + kdDebug(14170) << "WPEditAccount::validateData()"; + + if(mHostName->text().isEmpty()) { + KMessageBox::sorry(this, i18n("<qt>You must enter a valid screen name.</qt>"), i18n("WinPopup")); + return false; + } + + QFile smbc(mSmbcPath->url()); + if (!smbc.exists()) { + KMessageBox::sorry(this, i18n("<qt>You must enter a valid smbclient path.</qt>"), i18n("WinPopup")); + return false; + } + + return true; +} + +void WPEditAccount::writeConfig() +{ + KGlobal::config()->setGroup("WinPopup"); + KGlobal::config()->writeEntry("SmbcPath", mSmbcPath->url()); + KGlobal::config()->writeEntry("HostCheckFreq", mHostCheckFreq->text()); +} + +Kopete::Account *WPEditAccount::apply() +{ + kdDebug(14170) << "WPEditAccount::apply()"; + + if(!account()) + setAccount(new WPAccount(mProtocol, mHostName->text())); + +// account()->setExcludeConnect(mAutoConnect->isChecked()); + writeConfig(); + + mProtocol->settingsChanged(); + + return account(); +} + +#include "wpeditaccount.moc" + +// vim: set noet ts=4 sts=4 sw=4: +// kate: tab-width 4; indent-width 4; replace-trailing-space-save on; diff --git a/kopete/protocols/winpopup/wpeditaccount.h b/kopete/protocols/winpopup/wpeditaccount.h new file mode 100644 index 00000000..afa521a7 --- /dev/null +++ b/kopete/protocols/winpopup/wpeditaccount.h @@ -0,0 +1,57 @@ +/*************************************************************************** + wpeditaccount.h - description + ------------------- + begin : Wed Jan 23 2002 + copyright : (C) 2002 by Gav Wood + email : gav@kde.org + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef WPEDITACCOUNT_H +#define WPEDITACCOUNT_H + +// KDE Includes + +// QT Includes + +// Kopete Includes +#include "editaccountwidget.h" + +// Local Includes +#include "wpprotocol.h" +#include "wpaccount.h" +#include "wpeditaccountbase.h" + +namespace Kopete { class Account; } + +class WPEditAccount: public WPEditAccountBase, public KopeteEditAccountWidget +{ + Q_OBJECT + +private: + WPProtocol *mProtocol; + WPAccount *mAccount; + +public: + WPEditAccount(QWidget *parent, Kopete::Account *theAccount); + + virtual bool validateData(); + void writeConfig(); + +public slots: + virtual Kopete::Account *apply(); + virtual void installSamba(); +}; + +#endif + +// vim: set noet ts=4 sts=4 sw=4: +// kate: tab-width 4; indent-width 4; replace-trailing-space-save on; diff --git a/kopete/protocols/winpopup/wpprotocol.cpp b/kopete/protocols/winpopup/wpprotocol.cpp new file mode 100644 index 00000000..b765438c --- /dev/null +++ b/kopete/protocols/winpopup/wpprotocol.cpp @@ -0,0 +1,187 @@ +/*************************************************************************** + wpprotocol.cpp - WP Plugin + ------------------- + begin : Fri Apr 26 2002 + copyright : (C) 2002 by Gav Wood + email : gav@kde.org + + Based on code from : (C) 2002 by Duncan Mac-Vicar Prett + email : duncan@kde.org + *************************************************************************** + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +// QT Includes +#include <qmap.h> +#include <qdict.h> + +// KDE Includes +#include <kapplication.h> +#include <kdebug.h> +#include <kgenericfactory.h> +#include <kmessagebox.h> +#include <ksimpleconfig.h> +#include <kstandarddirs.h> + +// Kopete Includes +#include "kopeteaccountmanager.h" +#include "kopeteuiglobal.h" + +// Local Includes +#include "wpprotocol.h" +#include "wpeditaccount.h" +#include "wpaccount.h" +#include "wpcontact.h" + +class KPopupMenu; + +WPProtocol *WPProtocol::sProtocol = 0; + +typedef KGenericFactory<WPProtocol> WPProtocolFactory; +K_EXPORT_COMPONENT_FACTORY( kopete_wp, WPProtocolFactory( "kopete_wp" ) ) + +// WP Protocol +WPProtocol::WPProtocol( QObject *parent, const char *name, const QStringList & /* args */ ) +: Kopete::Protocol( WPProtocolFactory::instance(), parent, name ), + WPOnline( Kopete::OnlineStatus::Online, 25, this, 0, QString::null, i18n("Online"), i18n("Online")), + WPAway( Kopete::OnlineStatus::Away, 20, this, 1, "wp_away", i18n("Away"), i18n("Away")), + WPOffline( Kopete::OnlineStatus::Offline, 0, this, 2, QString::null, i18n("Offline"), i18n("Offline")) +{ +// kdDebug(14170) << "WPProtocol::WPProtocol()" << endl; + + sProtocol = this; + + // Load Status Actions +// initActions(); + // TODO: Maybe use this in the future? + + addAddressBookField( "messaging/winpopup", Kopete::Plugin::MakeIndexField ); + + readConfig(); + + popupClient = new WinPopupLib(smbClientBin, groupCheckFreq); + QObject::connect(popupClient, SIGNAL(signalNewMessage(const QString &, const QDateTime &, const QString &)), + this, SLOT(slotReceivedMessage(const QString &, const QDateTime &, const QString &))); +} + +// Destructor +WPProtocol::~WPProtocol() +{ +// kdDebug(14170) << "WPProtocol::~WPProtocol()" << endl; + + sProtocol = 0; +} + +AddContactPage *WPProtocol::createAddContactWidget(QWidget *parent, Kopete::Account *theAccount) +{ +// kdDebug(14170) << "WPProtocol::createAddContactWidget(<parent>, " << theAccount << ")" << endl; + + return new WPAddContact(parent, dynamic_cast<WPAccount *>(theAccount)); +} + +Kopete::Contact *WPProtocol::deserializeContact( Kopete::MetaContact *metaContact, + const QMap<QString, QString> &serializedData, + const QMap<QString, QString> & /* addressBookData */ ) +{ + QString contactId = serializedData[ "contactId" ]; + QString accountId = serializedData[ "accountId" ]; + + WPAccount *theAccount = static_cast<WPAccount *>(Kopete::AccountManager::self()->findAccount(protocol()->pluginId(), accountId)); + if(!theAccount) { + kdDebug(14170) << "Account " << accountId << " not found" << endl; + return 0; + } + + if(theAccount->contacts()[contactId]) { + kdDebug(14170) << "User " << contactId << " already in contacts map" << endl; + return 0; + } + + theAccount->addContact(contactId, metaContact, Kopete::Account::DontChangeKABC); + return theAccount->contacts()[contactId]; +} + +KopeteEditAccountWidget *WPProtocol::createEditAccountWidget(Kopete::Account *account, QWidget *parent) +{ + return new WPEditAccount(parent, account); +} + +Kopete::Account *WPProtocol::createNewAccount(const QString &accountId) +{ + return new WPAccount(this, accountId); +} + +void WPProtocol::settingsChanged() +{ + kdDebug(14170) << "WPProtocol::slotSettingsChanged()" << endl; + + readConfig(); + popupClient->settingsChanged(smbClientBin, groupCheckFreq); +} + +void WPProtocol::readConfig() +{ + KGlobal::config()->setGroup("WinPopup"); + smbClientBin = KGlobal::config()->readEntry("SmbcPath", "/usr/bin/smbclient"); + groupCheckFreq = KGlobal::config()->readNumEntry("HostCheckFreq", 60); +} + +void WPProtocol::installSamba() +{ +// kdDebug(14170) << "WPProtocol::installSamba()" endl; + + QStringList args; + args += KStandardDirs::findExe("winpopup-install.sh"); + args += KStandardDirs::findExe("winpopup-send.sh"); + if (KApplication::kdeinitExecWait("kdesu", args) == 0) + KMessageBox::information(Kopete::UI::Global::mainWidget(), i18n("The Samba configuration file is modified."), i18n("Configuration Succeeded")); + else + KMessageBox::error(Kopete::UI::Global::mainWidget(), i18n("Updating the Samba configuration file failed."), i18n("Configuration Failed")); +} + +/** + * search the contact for the new message and give it to its account + */ +void WPProtocol::slotReceivedMessage(const QString &Body, const QDateTime &Time, const QString &From) +{ + bool foundContact = false; + QString accountKey = QString::null; + QDict<Kopete::Account> Accounts = Kopete::AccountManager::self()->accounts(protocol()); + for (QDictIterator<Kopete::Account> it(Accounts); it.current(); ++it) { + QDict<Kopete::Contact> Contacts = it.current()->contacts(); + Kopete::Contact *theContact = Contacts[From]; + if (theContact != 0) { + foundContact = true; + dynamic_cast<WPAccount *>(it.current())->slotGotNewMessage(Body, Time, From); + break; + } + + if (accountKey.isEmpty() && it.current()->isConnected()) accountKey = it.currentKey(); + } + + // What to do with messages with no contact? + // Maybe send them to the next online account? GF + if (!foundContact) { + if (!accountKey.isEmpty()) + dynamic_cast<WPAccount *>(Accounts[accountKey])->slotGotNewMessage(Body, Time, From); + else + kdDebug(14170) << "No contact or connected account found!" << endl; + } +} + +void WPProtocol::sendMessage(const QString &Body, const QString &Destination) +{ + popupClient->sendMessage(Body, Destination); +} + +#include "wpprotocol.moc" + +// vim: set noet ts=4 sts=4 sw=4: +// kate: tab-width 4; indent-width 4; replace-trailing-space-save on; diff --git a/kopete/protocols/winpopup/wpprotocol.h b/kopete/protocols/winpopup/wpprotocol.h new file mode 100644 index 00000000..92a9e434 --- /dev/null +++ b/kopete/protocols/winpopup/wpprotocol.h @@ -0,0 +1,94 @@ +/*************************************************************************** + wpprotocol.h - Base class for the Kopete WP protocol + ------------------- + begin : Fri Apr 26 2002 + copyright : (C) 2002 by Gav Wood + email : gav@kde.org + + Based on code from : (C) 2002 by Duncan Mac-Vicar Prett + email : duncan@kde.org + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef WPPROTOCOL_H +#define WPPROTOCOL_H + +// QT Includes +#include <qpixmap.h> +#include <qptrlist.h> +#include <qdatetime.h> + +// Kopete Includes +#include "kopetemetacontact.h" +#include "kopeteprotocol.h" +#include "kopeteonlinestatus.h" + +// Local Includes +#include "libwinpopup.h" +#include "wpaddcontact.h" + +namespace Kopete { class Account; } +class KPopupMenu; +class KActionMenu; +class KAction; +class WPContact; +class WPAccount; + +/** + * The actual Protocol class used by Kopete. + */ +class WPProtocol : public Kopete::Protocol +{ + Q_OBJECT + +// Kopete::Protocol overloading +public: + WPProtocol( QObject *parent, const char *name, const QStringList &args ); + ~WPProtocol(); + + virtual AddContactPage *createAddContactWidget(QWidget *parent, Kopete::Account *theAccount); + virtual KopeteEditAccountWidget *createEditAccountWidget(Kopete::Account *account, QWidget *parent); + virtual Kopete::Account *createNewAccount(const QString &accountId); + + const QStringList getGroups() {return popupClient->getGroups(); } + const QStringList getHosts(const QString &Group) { return popupClient->getHosts(Group); } + bool checkHost(const QString &Name) { return popupClient->checkHost(Name); } + +// Kopete::Plugin overloading +public: + virtual Kopete::Contact *deserializeContact(Kopete::MetaContact *metaContact, const QMap<QString, QString> &serializedData, const QMap<QString, QString> &addressBookData); + +// Stuff used internally & by colleague classes +public: + static WPProtocol *protocol() { return sProtocol; } + + const Kopete::OnlineStatus WPOnline; + const Kopete::OnlineStatus WPAway; + const Kopete::OnlineStatus WPOffline; + void sendMessage(const QString &Body, const QString &Destination); + void settingsChanged(void); // Callback when settings changed + +public slots: + void installSamba(); // Modify smb.conf to use winpopup-send.sh script + void slotReceivedMessage(const QString &Body, const QDateTime &Time, const QString &From); + +private: + QString smbClientBin; + int groupCheckFreq; + void readConfig(); + WinPopupLib *popupClient; + static WPProtocol *sProtocol; // Singleton +}; + +#endif + +// vim: set noet ts=4 sts=4 sw=4: +// kate: tab-width 4; indent-width 4; replace-trailing-space-save on; diff --git a/kopete/protocols/winpopup/wpuserinfo.cpp b/kopete/protocols/winpopup/wpuserinfo.cpp new file mode 100644 index 00000000..7e4348d4 --- /dev/null +++ b/kopete/protocols/winpopup/wpuserinfo.cpp @@ -0,0 +1,114 @@ +/*************************************************************************** + wpuserinfo.cpp - WinPopup User Info + ------------------- + begin : Tue May 06 2003 + copyright : (C) 2003 by Tais M. Hansen + email : tais.hansen@osd.dk + + Based on code from : (C) 2002-2003 by the Kopete developers + email : kopete-devel@kde.org + *************************************************************************** + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +// QT Includes +#include <qregexp.h> + +// KDE Includes +#include <kdebug.h> +#include <klocale.h> +#include <klineedit.h> +#include <ksimpleconfig.h> + +// Local Includes +#include "wpuserinfo.h" +#include "wpaccount.h" +#include "wpcontact.h" + +WPUserInfo::WPUserInfo( WPContact *contact, WPAccount */*account*/, QWidget *parent, const char* name ) + : KDialogBase( parent, name, false, QString::null, Close, Close, false ), m_contact(contact), + Comment(i18n("N/A")), Workgroup(i18n("N/A")), OS(i18n("N/A")), Software(i18n("N/A")) +{ +// kdDebug( 14170 ) << k_funcinfo << endl; + + setCaption( i18n( "User Info for %1" ).arg( m_contact->nickName() ) ); + + m_mainWidget = new WPUserInfoWidget( this, "WPUserInfo::m_mainWidget" ); + setMainWidget( m_mainWidget ); + + m_mainWidget->sComputerName->setText( m_contact->contactId() ); + + m_mainWidget->sComment->setText(i18n("Looking")); + m_mainWidget->sWorkgroup->setText(i18n("Looking")); + m_mainWidget->sOS->setText(i18n("Looking")); + m_mainWidget->sServer->setText(i18n("Looking")); + + connect( this, SIGNAL( closeClicked() ), this, SLOT( slotCloseClicked() ) ); + + startDetailsProcess(m_contact->contactId()); +} + +// I decided to do this direct here to avoid "Handstände" with signals and stuff +// if we would do this in libwinpopup. GF +void WPUserInfo::startDetailsProcess(const QString &host) +{ + KGlobal::config()->setGroup("WinPopup"); + QString theSMBClientPath = KGlobal::config()->readEntry("SMBClientPath", "/usr/bin/smbclient"); + + KProcIO *details = new KProcIO; + *details << theSMBClientPath << "-N" << "-E" << "-g" << "-L" << host << "-"; + + connect(details, SIGNAL(readReady(KProcIO *)), this, SLOT(slotDetailsProcessReady(KProcIO *))); + connect(details, SIGNAL(processExited(KProcess *)), this, SLOT(slotDetailsProcessExited(KProcess *))); + + if (!details->start(KProcess::NotifyOnExit, KProcess::Stderr)) { + slotDetailsProcessExited(details); + kdDebug(14170) << "DetailsProcess not started!" << endl; + } +} + +void WPUserInfo::slotDetailsProcessReady(KProcIO *d) +{ + QString tmpLine = QString::null; + QRegExp info("^Domain=\\[(.*)\\]\\sOS=\\[(.*)\\]\\sServer=\\[(.*)\\]$"), host("^Server\\|(.*)\\|(.*)$"); + + while (d->readln(tmpLine) > -1) { + if (info.search(tmpLine) != -1) { + Workgroup = info.cap(1); + OS = info.cap(2); + Software = info.cap(3); + } + if (host.search(tmpLine) != -1) { + Comment = host.cap(2); + } + } +} + +void WPUserInfo::slotDetailsProcessExited(KProcess *d) +{ + delete d; + + m_mainWidget->sComment->setText(Comment); + m_mainWidget->sWorkgroup->setText(Workgroup); + m_mainWidget->sOS->setText(OS); + m_mainWidget->sServer->setText(Software); +} + +void WPUserInfo::slotCloseClicked() +{ + kdDebug( 14170 ) << k_funcinfo << endl; + + emit closing(); +} + +#include "wpuserinfo.moc" + +// vim: set noet ts=4 sts=4 sw=4: +// kate: tab-width 4; indent-width 4; replace-trailing-space-save on; diff --git a/kopete/protocols/winpopup/wpuserinfo.h b/kopete/protocols/winpopup/wpuserinfo.h new file mode 100644 index 00000000..1c4ce0e9 --- /dev/null +++ b/kopete/protocols/winpopup/wpuserinfo.h @@ -0,0 +1,61 @@ +/*************************************************************************** + wpuserinfo.h - WinPopup User Info + ------------------- + begin : Tue May 06 2003 + copyright : (C) 2003 by Tais M. Hansen + email : tais.hansen@osd.dk + + Based on code from : (C) 2002-2003 by the Kopete developers + email : kopete-devel@kde.org + *************************************************************************** + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef WPUSERINFO_H +#define WPUSERINFO_H + +// KDE Includes +#include <kdialogbase.h> +#include <kprocio.h> + +// Local Includes +#include "wpuserinfowidget.h" + +class WPAccount; +class WPContact; + +class WPUserInfo : public KDialogBase +{ + Q_OBJECT + + public: + WPUserInfo( WPContact *, WPAccount *, QWidget *parent = 0, const char* name = "WPUserInfo" ); + + void startDetailsProcess(const QString &host); + + private slots: + void slotDetailsProcessReady(KProcIO *d); + void slotDetailsProcessExited(KProcess *d); + void slotCloseClicked(); + + signals: + void closing(); + + private: + WPContact *m_contact; + WPUserInfoWidget *m_mainWidget; + + QString Comment, Workgroup, OS, Software; +}; + +#endif + +// vim: set noet ts=4 sts=4 sw=4: +// kate: tab-width 4; indent-width 4; replace-trailing-space-save on; |