summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/sms
diff options
context:
space:
mode:
Diffstat (limited to 'kopete/protocols/sms')
-rw-r--r--kopete/protocols/sms/Makefile.am21
-rw-r--r--kopete/protocols/sms/icons/Makefile.am3
-rw-r--r--kopete/protocols/sms/icons/cr128-app-sms_protocol.pngbin0 -> 14177 bytes
-rw-r--r--kopete/protocols/sms/icons/cr16-app-sms_protocol.pngbin0 -> 1039 bytes
-rw-r--r--kopete/protocols/sms/icons/cr32-app-sms_protocol.pngbin0 -> 2760 bytes
-rw-r--r--kopete/protocols/sms/icons/cr48-app-sms_protocol.pngbin0 -> 5024 bytes
-rw-r--r--kopete/protocols/sms/icons/cr64-app-sms_protocol.pngbin0 -> 7219 bytes
-rw-r--r--kopete/protocols/sms/kopete_sms.desktop81
-rw-r--r--kopete/protocols/sms/serviceloader.cpp74
-rw-r--r--kopete/protocols/sms/serviceloader.h42
-rw-r--r--kopete/protocols/sms/services/Makefile.am18
-rw-r--r--kopete/protocols/sms/services/gsmlib.cpp462
-rw-r--r--kopete/protocols/sms/services/gsmlib.h151
-rw-r--r--kopete/protocols/sms/services/gsmlibprefs.ui100
-rw-r--r--kopete/protocols/sms/services/kopete_unix_serial.cpp445
-rw-r--r--kopete/protocols/sms/services/kopete_unix_serial.h70
-rw-r--r--kopete/protocols/sms/services/smsclient.cpp192
-rw-r--r--kopete/protocols/sms/services/smsclient.h65
-rw-r--r--kopete/protocols/sms/services/smsclientprefs.ui135
-rw-r--r--kopete/protocols/sms/services/smssend.cpp254
-rw-r--r--kopete/protocols/sms/services/smssend.h66
-rw-r--r--kopete/protocols/sms/services/smssendprefs.ui188
-rw-r--r--kopete/protocols/sms/services/smssendprovider.cpp288
-rw-r--r--kopete/protocols/sms/services/smssendprovider.h82
-rw-r--r--kopete/protocols/sms/smsaccount.cpp202
-rw-r--r--kopete/protocols/sms/smsaccount.h79
-rw-r--r--kopete/protocols/sms/smsaddcontactpage.cpp65
-rw-r--r--kopete/protocols/sms/smsaddcontactpage.h50
-rw-r--r--kopete/protocols/sms/smscontact.cpp142
-rw-r--r--kopete/protocols/sms/smscontact.h74
-rw-r--r--kopete/protocols/sms/smseditaccountwidget.cpp147
-rw-r--r--kopete/protocols/sms/smseditaccountwidget.h64
-rw-r--r--kopete/protocols/sms/smsprotocol.cpp97
-rw-r--r--kopete/protocols/sms/smsprotocol.h71
-rw-r--r--kopete/protocols/sms/smsservice.cpp63
-rw-r--r--kopete/protocols/sms/smsservice.h83
-rw-r--r--kopete/protocols/sms/smsuserpreferences.cpp63
-rw-r--r--kopete/protocols/sms/smsuserpreferences.h44
-rw-r--r--kopete/protocols/sms/ui/Makefile.am8
-rw-r--r--kopete/protocols/sms/ui/empty.cpp0
-rw-r--r--kopete/protocols/sms/ui/smsactprefs.ui435
-rw-r--r--kopete/protocols/sms/ui/smsadd.ui143
-rw-r--r--kopete/protocols/sms/ui/smsuserprefs.ui118
43 files changed, 4685 insertions, 0 deletions
diff --git a/kopete/protocols/sms/Makefile.am b/kopete/protocols/sms/Makefile.am
new file mode 100644
index 00000000..6a42aebc
--- /dev/null
+++ b/kopete/protocols/sms/Makefile.am
@@ -0,0 +1,21 @@
+METASOURCES = AUTO
+SUBDIRS = ui services icons
+AM_CPPFLAGS = -I$(srcdir)/ui \
+ -I./ui \
+ -I$(srcdir)/services \
+ -I./services \
+ $(KOPETE_INCLUDES) \
+ $(all_includes)
+
+kde_module_LTLIBRARIES = kopete_sms.la
+
+kopete_sms_la_SOURCES = smsaddcontactpage.cpp smscontact.cpp smseditaccountwidget.cpp \
+ smsprotocol.cpp serviceloader.cpp smsservice.cpp smsuserpreferences.cpp \
+ smsaccount.cpp
+kopete_sms_la_LDFLAGS = -no-undefined -module $(KDE_PLUGIN) $(all_libraries)
+kopete_sms_la_LIBADD = ./ui/libkopetesmsui.la \
+ ./services/libkopetesmsservices.la \
+ ../../libkopete/libkopete.la $(LIB_KIO)
+
+service_DATA = kopete_sms.desktop
+servicedir = $(kde_servicesdir)
diff --git a/kopete/protocols/sms/icons/Makefile.am b/kopete/protocols/sms/icons/Makefile.am
new file mode 100644
index 00000000..224eb420
--- /dev/null
+++ b/kopete/protocols/sms/icons/Makefile.am
@@ -0,0 +1,3 @@
+kopeteicondir = $(kde_datadir)/kopete/icons
+kopeteicon_ICON = AUTO
+
diff --git a/kopete/protocols/sms/icons/cr128-app-sms_protocol.png b/kopete/protocols/sms/icons/cr128-app-sms_protocol.png
new file mode 100644
index 00000000..732327e2
--- /dev/null
+++ b/kopete/protocols/sms/icons/cr128-app-sms_protocol.png
Binary files differ
diff --git a/kopete/protocols/sms/icons/cr16-app-sms_protocol.png b/kopete/protocols/sms/icons/cr16-app-sms_protocol.png
new file mode 100644
index 00000000..3bfa3627
--- /dev/null
+++ b/kopete/protocols/sms/icons/cr16-app-sms_protocol.png
Binary files differ
diff --git a/kopete/protocols/sms/icons/cr32-app-sms_protocol.png b/kopete/protocols/sms/icons/cr32-app-sms_protocol.png
new file mode 100644
index 00000000..16110804
--- /dev/null
+++ b/kopete/protocols/sms/icons/cr32-app-sms_protocol.png
Binary files differ
diff --git a/kopete/protocols/sms/icons/cr48-app-sms_protocol.png b/kopete/protocols/sms/icons/cr48-app-sms_protocol.png
new file mode 100644
index 00000000..82049813
--- /dev/null
+++ b/kopete/protocols/sms/icons/cr48-app-sms_protocol.png
Binary files differ
diff --git a/kopete/protocols/sms/icons/cr64-app-sms_protocol.png b/kopete/protocols/sms/icons/cr64-app-sms_protocol.png
new file mode 100644
index 00000000..527771f7
--- /dev/null
+++ b/kopete/protocols/sms/icons/cr64-app-sms_protocol.png
Binary files differ
diff --git a/kopete/protocols/sms/kopete_sms.desktop b/kopete/protocols/sms/kopete_sms.desktop
new file mode 100644
index 00000000..783aa416
--- /dev/null
+++ b/kopete/protocols/sms/kopete_sms.desktop
@@ -0,0 +1,81 @@
+[Desktop Entry]
+Type=Service
+X-Kopete-Version=1000900
+Icon=sms_protocol
+ServiceTypes=Kopete/Protocol
+X-Kopete-Messaging-Protocol=messaging/sms
+X-KDE-Library=kopete_sms
+X-KDE-PluginInfo-Author=Richard Lärkäng
+X-KDE-PluginInfo-Email=richard@goteborg.utfors.se
+X-KDE-PluginInfo-Name=kopete_sms
+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=SMS
+Name[bn]=এস-এম-এস
+Name[fa]=خدمت پیام کوتاه
+Name[hi]=एसएमएस
+Name[km]=សេវា​សារ​ខ្លីៗ
+Name[ne]=एस एम एस
+Name[zh_CN]=短信息
+Comment=Protocol to send SMS messages
+Comment[ar]=سيرسل البروتوكول رسالة عن طريق خدمة الرسائل القصيرة
+Comment[be]=Пратакол адпраўлення паведамленняў SMS
+Comment[bg]=Протокол за изпращане на SMS съобщения
+Comment[bn]=এস-এম-এস বার্তা পাঠাতে প্রোটোকল
+Comment[br]=Komenad evit kas kemennadoù SMS
+Comment[bs]=Protokol za slanje SMS poruka
+Comment[ca]=Protocol per a enviar missatges SMS
+Comment[cs]=Protokol k odesílání SMS zpráv
+Comment[cy]=Protocol i anfon negeseuon SMS
+Comment[da]=Protokol til at sende SMS-beskeder
+Comment[de]=Protokoll zur Versendung von SMS-Nachrichten
+Comment[el]=Πρωτόκολλο για αποστολή μηνυμάτων SMS
+Comment[es]=Protocolo de envío de SMS
+Comment[et]=Protokoll SMS-ide saatmiseks
+Comment[eu]=SMS mezuak bidaltzeko protokoloa
+Comment[fa]=قرارداد برای ارسال پیامهای کوتاه
+Comment[fi]=Yhteyskäytäntö SMS-viestien lähettämiseen
+Comment[fr]=Protocole pour envoyer des SMS
+Comment[ga]=Prótacal chun teachtaireachtaí SMS a sheoladh
+Comment[gl]=Protocolo para enviar mansaxes SMS
+Comment[he]=פרוטוקול שליחת הודעות SMS
+Comment[hi]=से जुड़ने का प्रोटोकॉल
+Comment[hr]=Protokol za slanje SMS poruka
+Comment[hu]=Protokoll SMS üzenetek küldéséhez
+Comment[is]=Samskiptamáti til að senda SMS skilaboð
+Comment[it]=Protocollo per inviare messaggi SMS
+Comment[ja]=SMS メッセージを送るプロトコル
+Comment[ka]=SMS შეტყობინებების გაგზავნის ოქმი
+Comment[kk]=SMS хабарларын жіберу протоколы
+Comment[km]=ពិធីការ​ដើម្បី​ផ្ញើ​សារ​ខ្លីៗ
+Comment[lt]=Protokolas SMS žinučių siuntimui
+Comment[mk]=Протокол за испраќање на SMS-пораки
+Comment[nb]=Protokoll for å sende SMS-meldinger
+Comment[nds]=Protokoll för't Sennen vun SMS-Narichten
+Comment[ne]=एस एम एस सन्देश पठाउने प्रोटोकल
+Comment[nl]=Protocol voor verzenden van SMS-berichten
+Comment[nn]=Protokoll for å senda SMS-meldingar
+Comment[pl]=Protokół wysyłania wiadomości SMS
+Comment[pt]=Protocolo para enviar mensagens SMS
+Comment[pt_BR]=Protocolo para o envio de mensagens SMS
+Comment[ro]=Protocol de trimis mesaje SMS
+Comment[ru]=Протокол отправки сообщений SMS
+Comment[sk]=Protokol pre posielanie správ SMS
+Comment[sl]=Protokol za pošiljanje SMS sporočil
+Comment[sr]=Протокол за слање SMS порука
+Comment[sr@Latn]=Protokol za slanje SMS poruka
+Comment[sv]=Protokoll för att skicka SMS-meddelanden
+Comment[ta]=SMS செய்தி அனுப்ப விதிமுறை
+Comment[tg]=Қарордод барои фиристодани SMS пайёмҳо
+Comment[tr]=SMS mesajları gönderme iletişim kuralı
+Comment[uk]=Протокол для відсилання SMS повідомлень
+Comment[uz]=SMS xabarlarni joʻnatish uchun protokol
+Comment[uz@cyrillic]=SMS хабарларни жўнатиш учун протокол
+Comment[wa]=Protocole po-z evoyî des messaedje SMS
+Comment[zh_CN]=发送短信息的协议
+Comment[zh_HK]=用來發送 SMS 訊息的通訊協定
+Comment[zh_TW]=送 SMS 訊息的協定
diff --git a/kopete/protocols/sms/serviceloader.cpp b/kopete/protocols/sms/serviceloader.cpp
new file mode 100644
index 00000000..8a64a6c0
--- /dev/null
+++ b/kopete/protocols/sms/serviceloader.cpp
@@ -0,0 +1,74 @@
+/* *************************************************************************
+ * copyright: (C) 2003 Richard Lrkng <nouseforaname@home.se> *
+ * copyright: (C) 2003 Gav Wood <gav@kde.org> *
+ *************************************************************************
+*/
+
+/* *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#include "config.h"
+
+#include <kmessagebox.h>
+#include <klocale.h>
+#include <kdebug.h>
+
+#include "serviceloader.h"
+#include "smssend.h"
+#include "smsclient.h"
+#ifdef INCLUDE_SMSGSM
+# include "gsmlib.h"
+#endif
+#include "kopeteuiglobal.h"
+
+SMSService* ServiceLoader::loadService(const QString& name, Kopete::Account* account)
+{
+ kdWarning( 14160 ) << k_funcinfo << endl;
+
+ SMSService* s;
+ if (name == "SMSSend")
+ s = new SMSSend(account);
+ else if (name == "SMSClient")
+ s = new SMSClient(account);
+#ifdef INCLUDE_SMSGSM
+ else if (name == "GSMLib")
+ s = new GSMLib(account);
+#endif
+ else
+ {
+ KMessageBox::sorry(Kopete::UI::Global::mainWidget(), i18n("Could not load service %1.").arg(name),
+ i18n("Error Loading Service"));
+ s = 0L;
+ }
+
+ return s;
+}
+
+QStringList ServiceLoader::services()
+{
+ QStringList toReturn;
+ toReturn.append("SMSSend");
+ toReturn.append("SMSClient");
+#ifdef INCLUDE_SMSGSM
+ toReturn.append("GSMLib");
+#endif
+ return toReturn;
+}
+
+
+/*
+ * Local variables:
+ * c-indentation-style: k&r
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
+// vim: set noet ts=4 sts=4 sw=4:
+
diff --git a/kopete/protocols/sms/serviceloader.h b/kopete/protocols/sms/serviceloader.h
new file mode 100644
index 00000000..fe29ebcc
--- /dev/null
+++ b/kopete/protocols/sms/serviceloader.h
@@ -0,0 +1,42 @@
+/* *************************************************************************
+ * copyright: (C) 2003 Richard Lrkng <nouseforaname@home.se> *
+ * copyright: (C) 2003 Gav Wood <gav@kde.org> *
+ *************************************************************************
+*/
+
+/* *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef SERVICELOADER_H
+#define SERVICELOADER_H
+
+#include "smsservice.h"
+#include <qstring.h>
+#include <qstringlist.h>
+
+class SMSContact;
+
+class ServiceLoader
+{
+public:
+ static SMSService* loadService(const QString& name, Kopete::Account* account);
+ static QStringList services();
+} ;
+
+#endif //SERVICELOADER_H
+/*
+ * Local variables:
+ * c-indentation-style: k&r
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
+// vim: set noet ts=4 sts=4 sw=4:
+
diff --git a/kopete/protocols/sms/services/Makefile.am b/kopete/protocols/sms/services/Makefile.am
new file mode 100644
index 00000000..e21f1505
--- /dev/null
+++ b/kopete/protocols/sms/services/Makefile.am
@@ -0,0 +1,18 @@
+METASOURCES = AUTO
+AM_CPPFLAGS = $(KOPETE_INCLUDES) \
+ -I$(srcdir)/.. \
+ -I.. \
+ $(all_includes)
+
+KDE_CXXFLAGS = $(USE_EXCEPTIONS)
+
+noinst_LTLIBRARIES = libkopetesmsservices.la
+
+
+libkopetesmsservices_la_SOURCES = smssend.cpp smssendprefs.ui smssendprovider.cpp \
+ smsclient.cpp smsclientprefs.ui gsmlib.cpp gsmlibprefs.ui kopete_unix_serial.cpp
+
+if include_smsgsm
+libkopetesmsservices_la_LIBADD = -lgsmme
+endif
+
diff --git a/kopete/protocols/sms/services/gsmlib.cpp b/kopete/protocols/sms/services/gsmlib.cpp
new file mode 100644
index 00000000..e9b0542b
--- /dev/null
+++ b/kopete/protocols/sms/services/gsmlib.cpp
@@ -0,0 +1,462 @@
+/* *************************************************************************
+ * copyright: (C) 2005 Justin Huff <jjhuff@mspin.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. *
+ * *
+ *************************************************************************
+*/
+#include "config.h"
+#ifdef INCLUDE_SMSGSM
+
+#include <qcombobox.h>
+#include <qlayout.h>
+#include <qapplication.h>
+#include <qevent.h>
+#include <qmutex.h>
+#include <qthread.h>
+#include <qcheckbox.h>
+
+#include <klocale.h>
+#include <kurlrequester.h>
+#include <kmessagebox.h>
+#include <kprocess.h>
+#include <kdebug.h>
+#include <kconfigbase.h>
+
+#include <unistd.h>
+#include <gsmlib/gsm_me_ta.h>
+#include <gsmlib/gsm_sms.h>
+#include <gsmlib/gsm_util.h>
+#include <gsmlib/gsm_error.h>
+
+#include "kopeteaccount.h"
+#include "kopeteuiglobal.h"
+#include "kopetemetacontact.h"
+#include "kopetecontactlist.h"
+#include "kopetechatsessionmanager.h"
+
+#include "gsmlib.h"
+#include "gsmlibprefs.h"
+#include "smsprotocol.h"
+#include "smscontact.h"
+
+#include "kopete_unix_serial.h"
+
+/////////////////////////////////////////////////////////////////////
+#define GSMLIB_EVENT_ID 245
+GSMLibEvent::GSMLibEvent(SubType t) : QCustomEvent(QEvent::User+GSMLIB_EVENT_ID)
+{
+ setSubType(t);
+}
+
+GSMLibEvent::SubType GSMLibEvent::subType()
+{
+ return m_subType;
+}
+
+void GSMLibEvent::setSubType(GSMLibEvent::SubType t)
+{
+ m_subType = t;
+}
+
+/////////////////////////////////////////////////////////////////////
+GSMLibThread::GSMLibThread(QString dev, GSMLib* parent)
+{
+ m_device = dev;
+ m_parent = parent;
+ m_run = true;
+ m_MeTa = NULL;
+}
+
+GSMLibThread::~GSMLibThread()
+{
+ m_run = false;
+}
+
+void GSMLibThread::stop()
+{
+ m_run = false;
+ kdDebug( 14160 ) << "Waiting from GSMLibThread to die"<<endl;
+ if( wait(4000) == false )
+ kdWarning( 14160 ) << "GSMLibThread didn't exit!"<<endl;
+}
+void GSMLibThread::run()
+{
+ if( doConnect() )
+ {
+ while( m_run )
+ {
+ pollForMessages();
+ sendMessageQueue();
+ }
+ }
+
+ delete m_MeTa;
+ m_MeTa = NULL;
+ QApplication::postEvent(m_parent, new GSMLibEvent(GSMLibEvent::DISCONNECTED));
+ kdDebug( 14160 ) << "GSMLibThread exited"<<endl;
+}
+
+void GSMLibThread::send(const Kopete::Message& msg)
+{
+ if( m_MeTa )
+ {
+ m_outMessagesMutex.lock();
+ m_outMessages.push_back(msg);
+ m_outMessagesMutex.unlock();
+ }
+ else
+ {
+ GSMLibEvent* e = new GSMLibEvent( GSMLibEvent::MSG_NOT_SENT );
+ e->Reason = QString("GSMLib: Not Connected");
+ e->Message = msg;
+ QApplication::postEvent(m_parent, e);
+ }
+}
+
+
+bool GSMLibThread::doConnect()
+{
+ // open the port and ME/TA
+ try
+ {
+ kdDebug( 14160 ) << "Connecting to: '"<<m_device<<"'"<<endl;
+
+ gsmlib::Ref<gsmlib::Port> port = new gsmlib::KopeteUnixSerialPort(m_device.latin1(), 9600, gsmlib::DEFAULT_INIT_STRING, false);
+
+ kdDebug( 14160 ) << "Port created"<<endl;
+
+ m_MeTa = new gsmlib::MeTa(port);
+ std::string dummy1, dummy2, receiveStoreName;
+ m_MeTa->getSMSStore(dummy1, dummy2, receiveStoreName );
+ m_MeTa->setSMSStore(receiveStoreName, 3);
+
+ m_MeTa->setMessageService(1);
+
+ // switch on SMS routing
+ m_MeTa->setSMSRoutingToTA(true, false, false, true);
+
+ m_MeTa->setEventHandler(this);
+ QApplication::postEvent(m_parent, new GSMLibEvent(GSMLibEvent::CONNECTED));
+ return true;
+ }
+ catch(gsmlib::GsmException &e)
+ {
+ kdWarning( 14160 ) << k_funcinfo<< e.what()<<endl;
+ m_run = false;
+ return false;
+ }
+}
+
+void GSMLibThread::SMSReception(gsmlib::SMSMessageRef newMessage, SMSMessageType messageType)
+{
+ try
+ {
+ IncomingMessage m;
+ m.Type = messageType;
+ m.Message = newMessage;
+
+ m_newMessages.push_back(m);
+ }
+ catch(gsmlib::GsmException &e)
+ {
+ kdWarning( 14160 ) << k_funcinfo<< e.what()<<endl;
+ m_run = false;
+ }
+}
+
+void GSMLibThread::SMSReceptionIndication(std::string storeName, unsigned int index, SMSMessageType messageType)
+{
+ kdDebug( 14160 ) << k_funcinfo << "New Message in store: "<<storeName.c_str() << endl;
+
+ try
+ {
+ if( messageType != gsmlib::GsmEvent::NormalSMS )
+ return;
+
+ IncomingMessage m;
+ m.Index = index;
+ m.StoreName = storeName.c_str();
+ m.Type = messageType;
+ m_newMessages.push_back(m);
+ }
+ catch(gsmlib::GsmException &e)
+ {
+ kdWarning( 14160 ) << k_funcinfo<< e.what()<<endl;
+ m_run = false;
+ }
+}
+
+void GSMLibThread::pollForMessages( )
+{
+ if( m_MeTa == NULL )
+ return;
+
+ try
+ {
+ struct timeval timeoutVal;
+ timeoutVal.tv_sec = 1;
+ timeoutVal.tv_usec = 0;
+ m_MeTa->waitEvent(&timeoutVal);
+
+ MessageList::iterator it;
+ for( it=m_newMessages.begin(); it!=m_newMessages.end(); it++)
+ {
+ IncomingMessage m = *it;
+
+ // Do we need to fetch it from the ME?
+ if( m.Message.isnull() )
+ {
+ gsmlib::SMSStoreRef store = m_MeTa->getSMSStore(m.StoreName.latin1());
+ store->setCaching(false);
+
+ m.Message = (*store.getptr())[m.Index].message();
+ store->erase(store->begin() + m.Index);
+ }
+
+ GSMLibEvent* e = new GSMLibEvent( GSMLibEvent::NEW_MESSAGE );
+ e->Text = m.Message->userData().c_str();
+ e->Number = m.Message->address().toString().c_str();
+
+ QApplication::postEvent(m_parent, e);
+
+ }
+ m_newMessages.clear();
+ }
+ catch(gsmlib::GsmException &e)
+ {
+ kdWarning( 14160 ) << k_funcinfo<< e.what()<<endl;
+ m_run = false;
+ }
+}
+
+void GSMLibThread::sendMessageQueue()
+{
+ QMutexLocker _(&m_outMessagesMutex);
+
+ if(m_outMessages.size() == 0 )
+ return;
+
+ KopeteMessageList::iterator it;
+ for( it=m_outMessages.begin(); it!=m_outMessages.end(); it++)
+ sendMessage(*it);
+ m_outMessages.clear();
+}
+
+void GSMLibThread::sendMessage(const Kopete::Message& msg)
+{
+ QString reason;
+
+ if (!m_MeTa)
+ {
+ GSMLibEvent* e = new GSMLibEvent( GSMLibEvent::MSG_NOT_SENT );
+ e->Reason = QString("GSMLib: Not Connected");
+ e->Message = msg;
+ QApplication::postEvent(m_parent, e);
+ }
+
+ QString message = msg.plainBody();
+ QString nr = msg.to().first()->contactId();
+
+ // send SMS
+ try
+ {
+ gsmlib::Ref<gsmlib::SMSSubmitMessage> submitSMS = new gsmlib::SMSSubmitMessage();
+ gsmlib::Address destAddr( nr.latin1() );
+ submitSMS->setDestinationAddress(destAddr);
+ m_MeTa->sendSMSs(submitSMS, message.latin1(), true);
+
+ GSMLibEvent* e = new GSMLibEvent( GSMLibEvent::MSG_SENT );
+ e->Message = msg;
+ QApplication::postEvent(m_parent, e);
+ }
+ catch(gsmlib::GsmException &e)
+ {
+ GSMLibEvent* ev = new GSMLibEvent( GSMLibEvent::MSG_NOT_SENT );
+ ev->Reason = QString("GSMLib: ") + e.what();
+ ev->Message = msg;
+ QApplication::postEvent(m_parent, ev);
+ }
+}
+
+/////////////////////////////////////////////////////////////////////
+
+GSMLib::GSMLib(Kopete::Account* account)
+ : SMSService(account)
+{
+ prefWidget = 0L;
+ m_thread = NULL;
+
+ loadConfig();
+}
+
+GSMLib::~GSMLib()
+{
+ disconnect();
+}
+
+void GSMLib::saveConfig()
+{
+ if( m_account != NULL )
+ {
+ KConfigGroup* c = m_account->configGroup();
+
+ c->writeEntry(QString("%1:%2").arg("GSMLib").arg("Device"), m_device);
+ }
+}
+
+void GSMLib::loadConfig()
+{
+ m_device = "/dev/bluetooth/rfcomm0";
+ if( m_account != NULL )
+ {
+ QString temp;
+ KConfigGroup* c = m_account->configGroup();
+
+ temp = c->readEntry(QString("%1:%2").arg("GSMLib").arg("Device"), QString::null);
+ if( temp != QString::null )
+ m_device = temp;
+ }
+}
+
+void GSMLib::connect()
+{
+
+ m_thread = new GSMLibThread(m_device, this);
+ m_thread->start();
+
+}
+
+void GSMLib::disconnect()
+{
+ kdDebug( 14160 ) << k_funcinfo <<endl;
+
+ if( m_thread )
+ {
+ m_thread->stop();
+ delete m_thread;
+ m_thread = NULL;
+ emit disconnected();
+ }
+
+}
+
+void GSMLib::setWidgetContainer(QWidget* parent, QGridLayout* layout)
+{
+ m_parent = parent;
+ m_layout = layout;
+ QWidget *configWidget = configureWidget(parent);
+ layout->addMultiCellWidget(configWidget, 0, 1, 0, 1);
+ configWidget->show();
+}
+
+void GSMLib::send(const Kopete::Message& msg)
+{
+ m_thread->send(msg);
+}
+
+QWidget* GSMLib::configureWidget(QWidget* parent)
+{
+
+ if (prefWidget == 0L)
+ prefWidget = new GSMLibPrefsUI(parent);
+
+ loadConfig();
+ prefWidget->device->setURL(m_device);
+
+ return prefWidget;
+}
+
+void GSMLib::savePreferences()
+{
+ if( prefWidget )
+ {
+ m_device = prefWidget->device->url();
+ }
+ saveConfig();
+}
+
+int GSMLib::maxSize()
+{
+ return 160;
+}
+
+void GSMLib::customEvent(QCustomEvent* e)
+{
+ if( e->type() != QEvent::User+GSMLIB_EVENT_ID )
+ return;
+
+ if( m_account == NULL )
+ return;
+
+ GSMLibEvent* ge = (GSMLibEvent*)e;
+
+ kdDebug( 14160 ) << "Got event "<<ge->subType()<<endl;
+ switch( ge->subType() )
+ {
+ case GSMLibEvent::CONNECTED:
+ emit connected();
+ break;
+ case GSMLibEvent::DISCONNECTED:
+ disconnect();
+ break;
+ case GSMLibEvent::MSG_SENT:
+ emit messageSent(ge->Message);
+ break;
+ case GSMLibEvent::MSG_NOT_SENT:
+ emit messageNotSent(ge->Message, ge->Reason);
+ break;
+ case GSMLibEvent::NEW_MESSAGE:
+ {
+ QString nr = ge->Number;
+ QString text = ge->Text;
+
+ // Locate a contact
+ SMSContact* contact = static_cast<SMSContact*>( m_account->contacts().find( nr ));
+ if ( contact==NULL )
+ {
+ // No contact found, make a new one
+ Kopete::MetaContact* metaContact = new Kopete::MetaContact ();
+ metaContact->setTemporary ( true );
+ contact = new SMSContact(m_account, nr, nr, metaContact );
+ Kopete::ContactList::self ()->addMetaContact( metaContact );
+ contact->setOnlineStatus( SMSProtocol::protocol()->SMSOnline );
+ }
+
+ // Deliver the msg
+ Kopete::Message msg( contact, m_account->myself(), text, Kopete::Message::Inbound, Kopete::Message::RichText );
+ contact->manager(Kopete::Contact::CanCreate)->appendMessage( msg );
+ break;
+ }
+ }
+}
+
+
+
+
+const QString& GSMLib::description()
+{
+ QString url = "http://www.pxh.de/fs/gsmlib/";
+ m_description = i18n("<qt>GSMLib is a library (and utilities) for sending SMS via a GSM device. The program can be found on <a href=\"%1\">%1</a></qt>").arg(url).arg(url);
+ return m_description;
+}
+
+#include "gsmlib.moc"
+
+#endif
+/*
+ * Local variables:
+ * c-indentation-style: k&r
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
+// vim: set noet ts=4 sts=4 sw=4:
+
diff --git a/kopete/protocols/sms/services/gsmlib.h b/kopete/protocols/sms/services/gsmlib.h
new file mode 100644
index 00000000..fa9ef1d2
--- /dev/null
+++ b/kopete/protocols/sms/services/gsmlib.h
@@ -0,0 +1,151 @@
+/* *************************************************************************
+ * copyright: (C) 2005 Justin Huff <jjhuff@mspin.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 GSMLIB_H_039562406
+#define GSMLIB_H_039562406
+
+#include "config.h"
+#ifdef INCLUDE_SMSGSM
+
+#include <unistd.h>
+
+#include <gsmlib/gsm_unix_serial.h>
+#include <gsmlib/gsm_sms.h>
+#include <gsmlib/gsm_me_ta.h>
+#include <gsmlib/gsm_util.h>
+#include <gsmlib/gsm_event.h>
+
+#include "smsservice.h"
+#include "kopetemessage.h"
+
+#include <qobject.h>
+#include <qevent.h>
+#include <qthread.h>
+#include <qmutex.h>
+#include <qvaluelist.h>
+#include <qstringlist.h>
+
+class GSMLibPrefsUI;
+class SMSContact;
+class QListViewItem;
+class KProcess;
+class GSMLibThread;
+
+class GSMLib : public SMSService
+{
+ Q_OBJECT
+public:
+ GSMLib(Kopete::Account* account);
+ ~GSMLib();
+
+ void send(const Kopete::Message& msg);
+ void setWidgetContainer(QWidget* parent, QGridLayout* container);
+
+ int maxSize();
+ const QString& description();
+
+public slots:
+ void savePreferences();
+ virtual void connect();
+ virtual void disconnect();
+
+//signals:
+// void messageSent(const Kopete::Message &);
+protected:
+ virtual void customEvent(QCustomEvent* e);
+
+ QWidget* configureWidget(QWidget* parent);
+ void saveConfig();
+ void loadConfig();
+
+ GSMLibPrefsUI* prefWidget;
+ QStringList output;
+
+ QString m_device;
+
+ QString m_description;
+
+ GSMLibThread* m_thread;
+
+} ;
+
+
+/// Custom event for async-events
+class GSMLibEvent : public QCustomEvent
+{
+public:
+ enum SubType { CONNECTED, DISCONNECTED, NEW_MESSAGE, MSG_SENT, MSG_NOT_SENT };
+
+ GSMLibEvent(SubType t);
+
+ SubType subType();
+ void setSubType(SubType t);
+
+ QString Text;
+ QString Number;
+
+ QString Reason;
+
+ Kopete::Message Message;
+protected:
+ SubType m_subType;
+};
+
+/// Thread to deal with GsmLib's blocking
+class GSMLibThread : public QThread, gsmlib::GsmEvent
+{
+public:
+ GSMLibThread(QString dev, GSMLib* parent);
+ virtual ~GSMLibThread();
+
+ virtual void run();
+ void stop();
+ void send(const Kopete::Message& msg);
+protected:
+ bool doConnect();
+ void pollForMessages();
+ void sendMessageQueue();
+ void sendMessage(const Kopete::Message& msg);
+ void SMSReception(gsmlib::SMSMessageRef newMessage, SMSMessageType messageType);
+ void SMSReceptionIndication(std::string storeName, unsigned int index, SMSMessageType messageType);
+
+ GSMLib* m_parent;
+ QString m_device;
+
+ gsmlib::MeTa* m_MeTa;
+
+ bool m_run;
+
+ struct IncomingMessage
+ {
+ int Index;
+ QString StoreName;
+ gsmlib::SMSMessageRef Message;
+ GsmEvent::SMSMessageType Type;
+
+ IncomingMessage() : Index(-1)
+ {}
+ };
+
+ typedef QValueList<IncomingMessage> MessageList;
+ MessageList m_newMessages;
+
+ typedef QValueList<Kopete::Message> KopeteMessageList;
+ KopeteMessageList m_outMessages;
+ QMutex m_outMessagesMutex;
+};
+
+#endif
+#endif //GSMLIB_H_039562406
diff --git a/kopete/protocols/sms/services/gsmlibprefs.ui b/kopete/protocols/sms/services/gsmlibprefs.ui
new file mode 100644
index 00000000..108f6326
--- /dev/null
+++ b/kopete/protocols/sms/services/gsmlibprefs.ui
@@ -0,0 +1,100 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>GSMLibPrefsUI</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>GSMLibPrefsUI</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>375</width>
+ <height>168</height>
+ </rect>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer16</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>321</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel8</cstring>
+ </property>
+ <property name="font">
+ <font>
+ <bold>1</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>GSMLib Settings</string>
+ </property>
+ </widget>
+ <widget class="Line">
+ <property name="name">
+ <cstring>line14</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout13</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Device:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>program</cstring>
+ </property>
+ </widget>
+ <widget class="KURLRequester" row="0" column="1">
+ <property name="name">
+ <cstring>device</cstring>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </vbox>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>kurlrequester.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+</includehints>
+</UI>
diff --git a/kopete/protocols/sms/services/kopete_unix_serial.cpp b/kopete/protocols/sms/services/kopete_unix_serial.cpp
new file mode 100644
index 00000000..b694ab22
--- /dev/null
+++ b/kopete/protocols/sms/services/kopete_unix_serial.cpp
@@ -0,0 +1,445 @@
+// *************************************************************************
+// * Taken from the GSM TA/ME library
+// *
+// * File: gsm_unix_port.cc
+// *
+// * Purpose: UNIX serial port implementation with extras
+// *
+// * Original Author: Peter Hofmann (software@pxh.de)
+// * Modified by: Justin Huff (jjhuff@mspin.net)
+// *
+// * Created: 10.5.1999
+// *************************************************************************
+#include "config.h"
+#ifdef INCLUDE_SMSGSM
+
+#include <gsmlib/gsm_util.h>
+#include <termios.h>
+#include <fcntl.h>
+#include <iostream>
+#include <sstream>
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <signal.h>
+#include <pthread.h>
+#include <cassert>
+#include <assert.h>
+
+#include <qsocketnotifier.h>
+
+#include "kopete_unix_serial.h"
+
+using namespace std;
+using namespace gsmlib;
+
+static const int holdoff[] = {2000000, 1000000, 400000};
+static const int holdoffArraySize = sizeof(holdoff)/sizeof(int);
+
+// alarm handling for socket read/write
+// the timerMtx is necessary since several threads cannot use the
+// timer indepently of each other
+
+static pthread_mutex_t timerMtx = PTHREAD_MUTEX_INITIALIZER;
+#define pthread_mutex_lock(x)
+#define pthread_mutex_unlock(x)
+
+// for non-GNU systems, define alarm()
+#ifndef HAVE_ALARM
+unsigned int alarm(unsigned int seconds)
+{
+ struct itimerval old, newt;
+ newt.it_interval.tv_usec = 0;
+ newt.it_interval.tv_sec = 0;
+ newt.it_value.tv_usec = 0;
+ newt.it_value.tv_sec = (long int)seconds;
+ if (setitimer(ITIMER_REAL, &newt, &old) < 0)
+ return 0;
+ else
+ return old.it_value.tv_sec;
+}
+#endif
+
+// this routine is called in case of a timeout
+static void catchAlarm(int)
+{
+ // do nothing
+}
+
+// start timer
+static void startTimer()
+{
+ pthread_mutex_lock(&timerMtx);
+ struct sigaction newAction;
+ newAction.sa_handler = catchAlarm;
+ newAction.sa_flags = 0;
+ sigaction(SIGALRM, &newAction, NULL);
+ alarm(1);
+}
+
+// reset timer
+static void stopTimer()
+{
+ alarm(0);
+ sigaction(SIGALRM, NULL, NULL);
+ pthread_mutex_unlock(&timerMtx);
+}
+
+// KopeteUnixSerialPort members
+
+void KopeteUnixSerialPort::throwModemException(string message) throw(GsmException)
+{
+ ostringstream os;
+ os << message << " (errno: " << errno << "/" << strerror(errno) << ")";
+ throw GsmException(os.str(), OSError, errno);
+}
+
+void KopeteUnixSerialPort::putBack(unsigned char c)
+{
+ assert(_oldChar == -1);
+ _oldChar = c;
+}
+
+int KopeteUnixSerialPort::readByte() throw(GsmException)
+{
+ if (_oldChar != -1)
+ {
+ int result = _oldChar;
+ _oldChar = -1;
+ return result;
+ }
+
+ unsigned char c;
+ int timeElapsed = 0;
+ struct timeval oneSecond;
+ bool readDone = false;
+
+ while (! readDone && timeElapsed < _timeoutVal)
+ {
+ if (interrupted())
+ throwModemException("interrupted when reading from TA");
+
+ // setup fd_set data structure for select()
+ fd_set fdSet;
+ oneSecond.tv_sec = 1;
+ oneSecond.tv_usec = 0;
+ FD_ZERO(&fdSet);
+ FD_SET(_fd, &fdSet);
+
+ switch (select(FD_SETSIZE, &fdSet, NULL, NULL, &oneSecond))
+ {
+ case 1:
+ {
+ int res = read(_fd, &c, 1);
+ if (res != 1)
+ throwModemException("end of file when reading from TA");
+ else
+ readDone = true;
+ break;
+ }
+ case 0:
+ ++timeElapsed;
+ break;
+ default:
+ if (errno != EINTR)
+ throwModemException("reading from TA");
+ break;
+ }
+ }
+ if (! readDone)
+ throwModemException("timeout when reading from TA");
+
+#ifndef NDEBUG
+ if (debugLevel() >= 2)
+ {
+ // some useful debugging code
+ if (c == LF)
+ cerr << "<LF>";
+ else if (c == CR)
+ cerr << "<CR>";
+ else cerr << "<'" << (char) c << "'>";
+ cerr.flush();
+ }
+#endif
+ return c;
+}
+
+KopeteUnixSerialPort::KopeteUnixSerialPort(string device, speed_t lineSpeed,
+ string initString, bool swHandshake)
+ throw(GsmException) :
+ _oldChar(-1), _timeoutVal(TIMEOUT_SECS)
+{
+ _readNotifier = NULL;
+
+ struct termios t;
+
+ // open device
+ _fd = open(device.c_str(), O_RDWR | O_NOCTTY | O_NONBLOCK);
+ if (_fd == -1)
+ throwModemException("opening device");
+
+ // switch off non-blocking mode
+ int fdFlags;
+ if ((fdFlags = fcntl(_fd, F_GETFL)) == -1)
+ {
+ close(_fd);
+ throwModemException("getting file status flags failed");
+ }
+ fdFlags &= ~O_NONBLOCK;
+ if (fcntl(_fd, F_SETFL, fdFlags) == -1)
+ {
+ close(_fd);
+ throwModemException("switching of non-blocking mode failed");
+ }
+
+ // Set the close on exec flag
+ if ((fdFlags = fcntl(_fd, F_GETFD)) == -1)
+ {
+ close(_fd);
+ throwModemException("getting file status flags failed");
+ }
+ fdFlags |= FD_CLOEXEC;
+ if (fcntl(_fd, F_SETFD, fdFlags) == -1)
+ {
+ close(_fd);
+ throwModemException("switching of non-blocking mode failed");
+ }
+
+ long int saveTimeoutVal = _timeoutVal;
+ _timeoutVal = 3;
+ int initTries = holdoffArraySize;
+ while (initTries-- > 0)
+ {
+ // flush all pending output
+ tcflush(_fd, TCOFLUSH);
+
+ // toggle DTR to reset modem
+ int mctl = TIOCM_DTR;
+ if (ioctl(_fd, TIOCMBIC, &mctl) < 0 && errno != ENOTTY)
+ {
+ close(_fd);
+ throwModemException("clearing DTR failed");
+ }
+ // the waiting time for DTR toggling is increased with each loop
+ usleep(holdoff[initTries]);
+ if (ioctl(_fd, TIOCMBIS, &mctl) < 0 && errno != ENOTTY)
+ {
+ close(_fd);
+ throwModemException("setting DTR failed");
+ }
+ // get line modes
+ if (tcgetattr(_fd, &t) < 0)
+ {
+ close(_fd);
+ throwModemException("tcgetattr device");
+ }
+
+ // set line speed
+ cfsetispeed(&t, lineSpeed);
+ cfsetospeed(&t, lineSpeed);
+
+ // set the device to a sane state
+ t.c_iflag |= IGNPAR | (swHandshake ? IXON | IXOFF : 0);
+ t.c_iflag &= ~(INPCK | ISTRIP | IMAXBEL |
+ (swHandshake ? 0 : IXON | IXOFF)
+ | IXANY | IGNCR | ICRNL | IMAXBEL | INLCR | IGNBRK);
+ t.c_oflag &= ~(OPOST);
+ // be careful, only touch "known" flags
+ t.c_cflag &= ~(CSIZE | CSTOPB | PARENB | PARODD |
+ (swHandshake ? CRTSCTS : 0 ));
+ t.c_cflag |= CS8 | CREAD | HUPCL | (swHandshake ? 0 : CRTSCTS) | CLOCAL;
+ t.c_lflag &= ~(ECHO | ECHOE | ECHOPRT | ECHOK | ECHOKE | ECHONL |
+ ECHOCTL | ISIG | IEXTEN | TOSTOP | FLUSHO | ICANON);
+ t.c_lflag |= NOFLSH;
+ t.c_cc[VMIN] = 1;
+ t.c_cc[VTIME] = 0;
+
+ t.c_cc[VSUSP] = 0;
+
+ // write back
+ if(tcsetattr (_fd, TCSANOW, &t) < 0)
+ {
+ close(_fd);
+ throwModemException("tcsetattr device");
+ }
+ // the waiting time for writing to the ME/TA is increased with each loop
+ usleep(holdoff[initTries]);
+
+ // flush all pending input
+ tcflush(_fd, TCIFLUSH);
+
+ try
+ {
+ // reset modem
+ putLine("ATZ");
+ bool foundOK = false;
+ int readTries = 5;
+ while (readTries-- > 0)
+ {
+ // for the first call getLine() waits only 3 seconds
+ // because of _timeoutVal = 3
+ string s = getLine();
+ if (s.find("OK") != string::npos ||
+ s.find("CABLE: GSM") != string::npos)
+ {
+ foundOK = true;
+ readTries = 0; // found OK, exit loop
+ }
+ else if (s.find("ERROR") != string::npos)
+ readTries = 0; // error, exit loop
+ }
+
+ // set getLine/putLine timeout back to old value
+ _timeoutVal = saveTimeoutVal;
+
+ if (foundOK)
+ {
+ // init modem
+ readTries = 5;
+ putLine("AT" + initString);
+ while (readTries-- > 0)
+ {
+ string s = getLine();
+ if (s.find("OK") != string::npos ||
+ s.find("CABLE: GSM") != string::npos)
+ {
+ _readNotifier = new QSocketNotifier(_fd, QSocketNotifier::Read);
+ connect( _readNotifier, SIGNAL(activated(int)), this, SIGNAL(activated()));
+ return; // found OK, return
+ }
+ }
+ }
+ }
+ catch (GsmException &e)
+ {
+ _timeoutVal = saveTimeoutVal;
+ if (initTries == 0)
+ {
+ close(_fd);
+ throw e;
+ }
+ }
+ }
+ // no response after 3 tries
+ close(_fd);
+ throwModemException("reset modem failed");
+}
+
+string KopeteUnixSerialPort::getLine() throw(GsmException)
+{
+ string result;
+ int c;
+ while ((c = readByte()) >= 0)
+ {
+ while (c == CR)
+ {
+ c = readByte();
+ }
+ if (c == LF)
+ break;
+ result += c;
+ }
+
+#ifndef NDEBUG
+ if (debugLevel() >= 1)
+ cerr << "<-- " << result << endl;
+#endif
+
+ return result;
+}
+
+void KopeteUnixSerialPort::putLine(string line,
+ bool carriageReturn) throw(GsmException)
+{
+#ifndef NDEBUG
+ if (debugLevel() >= 1)
+ cerr << "--> " << line << endl;
+#endif
+
+ if (carriageReturn) line += CR;
+ const char *l = line.c_str();
+
+ int timeElapsed = 0;
+ struct timeval oneSecond;
+
+ ssize_t bytesWritten = 0;
+ while (bytesWritten < (ssize_t)line.length() && timeElapsed < _timeoutVal)
+ {
+ if (interrupted())
+ throwModemException("interrupted when writing to TA");
+
+ // setup fd_set data structure for select()
+ fd_set fdSet;
+ oneSecond.tv_sec = 1;
+ oneSecond.tv_usec = 0;
+ FD_ZERO(&fdSet);
+ FD_SET(_fd, &fdSet);
+
+ switch (select(FD_SETSIZE, NULL, &fdSet, NULL, &oneSecond))
+ {
+ case 1:
+ {
+ ssize_t bw = write(_fd, l + bytesWritten, line.length() - bytesWritten);
+ if (bw < 0)
+ throwModemException("writing to TA");
+ bytesWritten += bw;
+ break;
+ }
+ case 0:
+ ++timeElapsed;
+ break;
+ default:
+ if (errno != EINTR)
+ throwModemException("writing to TA");
+ break;
+ }
+ }
+
+ while (timeElapsed < _timeoutVal)
+ {
+ if (interrupted())
+ throwModemException("interrupted when writing to TA");
+ ::startTimer();
+ int res = tcdrain(_fd); // wait for output to be read by TA
+ ::stopTimer();
+ if (res == 0)
+ break;
+ else
+ {
+ assert(errno == EINTR);
+ ++timeElapsed;
+ }
+ }
+ if (timeElapsed >= _timeoutVal)
+ throwModemException("timeout when writing to TA");
+
+ // echo CR LF must be removed by higher layer functions in gsm_at because
+ // in order to properly handle unsolicited result codes from the ME/TA
+}
+
+bool KopeteUnixSerialPort::wait(GsmTime timeout) throw(GsmException)
+{
+ fd_set fds;
+ FD_ZERO(&fds);
+ FD_SET(_fd, &fds);
+ return select(FD_SETSIZE, &fds, NULL, NULL, timeout) != 0;
+}
+
+// set timeout for read or write in seconds.
+void KopeteUnixSerialPort::setTimeOut(unsigned int timeout)
+{
+ _timeoutVal = timeout;
+}
+
+KopeteUnixSerialPort::~KopeteUnixSerialPort()
+{
+ delete _readNotifier;
+ _readNotifier = NULL;
+ if (_fd != -1)
+ close(_fd);
+}
+
+#include "kopete_unix_serial.moc"
+
+#endif
diff --git a/kopete/protocols/sms/services/kopete_unix_serial.h b/kopete/protocols/sms/services/kopete_unix_serial.h
new file mode 100644
index 00000000..0248556b
--- /dev/null
+++ b/kopete/protocols/sms/services/kopete_unix_serial.h
@@ -0,0 +1,70 @@
+// *************************************************************************
+// * Taken from the GSM TA/ME library
+// *
+// * File: gsm_unix_port.h
+// *
+// * Purpose: UNIX serial port implementation with extras
+// *
+// * Original Author: Peter Hofmann (software@pxh.de)
+// * Modified by: Justin Huff (jjhuff@mspin.net)
+// *
+// * Created: 4.5.1999
+// *************************************************************************
+
+#ifndef GSM_UNIX_SERIAL_KOPETE_H
+#define GSM_UNIX_SERIAL_KOPETE_H
+
+#include "config.h"
+#ifdef INCLUDE_SMSGSM
+
+#include <string>
+#include <gsmlib/gsm_error.h>
+#include <gsmlib/gsm_port.h>
+#include <gsmlib/gsm_util.h>
+#include <sys/types.h>
+#include <termios.h>
+
+#include <qobject.h>
+
+class QSocketNotifier;
+namespace gsmlib
+{
+
+class KopeteUnixSerialPort : public QObject, public Port
+{
+ Q_OBJECT;
+
+protected:
+ int _fd; // file descriptor for device
+ int _oldChar; // character set by putBack() (-1 == none)
+ long int _timeoutVal; // timeout for getLine/readByte
+
+ QSocketNotifier* _readNotifier;
+
+ // throw GsmException include UNIX errno
+ void throwModemException(std::string message) throw(GsmException);
+
+public:
+ // create Port given the UNIX device name
+ KopeteUnixSerialPort(std::string device, speed_t lineSpeed = DEFAULT_BAUD_RATE,
+ std::string initString = DEFAULT_INIT_STRING,
+ bool swHandshake = false)
+ throw(GsmException);
+ virtual ~KopeteUnixSerialPort();
+
+ // inherited from Port
+ void putBack(unsigned char c);
+ int readByte() throw(GsmException);
+ std::string getLine() throw(GsmException);
+ void putLine(std::string line,
+ bool carriageReturn = true) throw(GsmException);
+ bool wait(GsmTime timeout) throw(GsmException);
+ void setTimeOut(unsigned int timeout);
+
+signals:
+ void activated();
+};
+
+}
+#endif
+#endif // GSM_UNIX_SERIAL_KOPETE_H
diff --git a/kopete/protocols/sms/services/smsclient.cpp b/kopete/protocols/sms/services/smsclient.cpp
new file mode 100644
index 00000000..96c04818
--- /dev/null
+++ b/kopete/protocols/sms/services/smsclient.cpp
@@ -0,0 +1,192 @@
+/* *************************************************************************
+ * copyright: (C) 2003 Richard Lrkng <nouseforaname@home.se> *
+ * copyright: (C) 2003 Gav Wood <gav@kde.org> *
+ *************************************************************************
+*/
+
+/* *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#include <qcombobox.h>
+#include <qlayout.h>
+
+#include <klocale.h>
+#include <kurlrequester.h>
+#include <kmessagebox.h>
+#include <kprocess.h>
+#include <kdebug.h>
+#include <kconfigbase.h>
+
+#include "kopeteaccount.h"
+#include "kopeteuiglobal.h"
+
+#include "smsclient.h"
+#include "smsclientprefs.h"
+#include "smsprotocol.h"
+
+SMSClient::SMSClient(Kopete::Account* account)
+ : SMSService(account)
+{
+ prefWidget = 0L;
+}
+
+SMSClient::~SMSClient()
+{
+}
+
+void SMSClient::setWidgetContainer(QWidget* parent, QGridLayout* layout)
+{
+ kdWarning( 14160 ) << k_funcinfo << "ml: " << layout << ", " << "mp: " << parent << endl;
+ m_parent = parent;
+ m_layout = layout;
+ QWidget *configWidget = configureWidget(parent);
+ layout->addMultiCellWidget(configWidget, 0, 1, 0, 1);
+ configWidget->show();
+}
+
+void SMSClient::send(const Kopete::Message& msg)
+{
+ kdWarning( 14160 ) << k_funcinfo << "m_account = " << m_account << " (should be non-zero!!)" << endl;
+ if (!m_account) return;
+
+ m_msg = msg;
+
+ KConfigGroup* c = m_account->configGroup();
+ QString provider = c->readEntry(QString("%1:%2").arg("SMSClient").arg("ProviderName"), QString::null);
+
+ if (provider.isNull())
+ {
+ KMessageBox::error(Kopete::UI::Global::mainWidget(), i18n("No provider configured"), i18n("Could Not Send Message"));
+ return;
+ }
+
+ QString programName = c->readEntry(QString("%1:%2").arg("SMSClient").arg("ProgramName"). QString::null);
+ if (programName.isNull())
+ programName = "/usr/bin/sms_client";
+
+ KProcess* p = new KProcess;
+
+ QString message = msg.plainBody();
+ QString nr = msg.to().first()->contactId();
+
+ *p << programName;
+ *p << provider + ":" + nr;
+ *p << message;
+
+ QObject::connect(p, SIGNAL(processExited(KProcess *)), this, SLOT(slotSendFinished(KProcess*)));
+ QObject::connect(p, SIGNAL(receivedStdout(KProcess*, char*, int)), this, SLOT(slotReceivedOutput(KProcess*, char*, int)));
+ QObject::connect(p, SIGNAL(receivedStderr(KProcess*, char*, int)), this, SLOT(slotReceivedOutput(KProcess*, char*, int)));
+
+ p->start(KProcess::Block, KProcess::AllOutput);
+}
+
+QWidget* SMSClient::configureWidget(QWidget* parent)
+{
+ kdWarning( 14160 ) << k_funcinfo << "m_account = " << m_account << " (should be ok if zero!!)" << endl;
+
+ if (prefWidget == 0L)
+ prefWidget = new SMSClientPrefsUI(parent);
+
+ prefWidget->configDir->setMode(KFile::Directory);
+ QString configDir;
+ if (m_account)
+ configDir = m_account->configGroup()->readEntry(QString("%1:%2").arg("SMSClient").arg("ConfigDir"), QString::null);
+ if (configDir.isNull())
+ configDir = "/etc/sms";
+ prefWidget->configDir->setURL(configDir);
+
+ QString programName;
+ if (m_account)
+ programName = m_account->configGroup()->readEntry(QString("%1:%2").arg("SMSClient").arg("ProgramName"),
+ QString::null);
+ if (programName.isNull())
+ programName = "/usr/bin/sms_client";
+ prefWidget->program->setURL(programName);
+
+ prefWidget->provider->insertStringList(providers());
+
+ if (m_account)
+ {
+ QString pName = m_account->configGroup()->readEntry(QString("%1:%2").arg("SMSClient").arg("ProviderName"));
+ for (int i=0; i < prefWidget->provider->count(); i++)
+ {
+ if (prefWidget->provider->text(i) == pName)
+ {
+ prefWidget->provider->setCurrentItem(i);
+ break;
+ }
+ }
+ }
+
+ return prefWidget;
+}
+
+void SMSClient::savePreferences()
+{
+ kdWarning( 14160 ) << k_funcinfo << "m_account = " << m_account << " (should be work if zero!!)" << endl;
+
+ if (prefWidget != 0L && m_account != 0L)
+ {
+ KConfigGroup* c = m_account->configGroup();
+
+ c->writeEntry(QString("%1:%2").arg("SMSClient").arg("ProgramName"), prefWidget->program->url());
+ c->writeEntry(QString("%1:%2").arg("SMSClient").arg("ConfigDir"), prefWidget->configDir->url());
+ c->writeEntry(QString("%1:%2").arg("SMSClient").arg("ProviderName"), prefWidget->provider->currentText());
+ }
+}
+
+QStringList SMSClient::providers()
+{
+ QStringList p;
+
+ QDir d;
+ d.setPath(QString("%1/services/").arg(prefWidget->configDir->url()));
+ p += d.entryList("*", QDir::Files);
+
+ return p;
+}
+
+void SMSClient::slotReceivedOutput(KProcess*, char *buffer, int buflen)
+{
+ QStringList lines = QStringList::split("\n", QString::fromLocal8Bit(buffer, buflen));
+ for (QStringList::Iterator it = lines.begin(); it != lines.end(); ++it)
+ output.append(*it);
+}
+
+void SMSClient::slotSendFinished(KProcess* p)
+{
+ if (p->exitStatus() == 0)
+ emit messageSent(m_msg);
+ else
+ emit messageNotSent(m_msg, output.join("\n"));
+}
+
+int SMSClient::maxSize()
+{
+ return 160;
+}
+
+const QString& SMSClient::description()
+{
+ QString url = "http://www.smsclient.org";
+ m_description = i18n("<qt>SMSClient is a program for sending SMS with the modem. The program can be found on <a href=\"%1\">%1</a></qt>").arg(url).arg(url);
+ return m_description;
+}
+
+#include "smsclient.moc"
+/*
+ * Local variables:
+ * c-indentation-style: k&r
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
+// vim: set noet ts=4 sts=4 sw=4:
+
diff --git a/kopete/protocols/sms/services/smsclient.h b/kopete/protocols/sms/services/smsclient.h
new file mode 100644
index 00000000..bc260228
--- /dev/null
+++ b/kopete/protocols/sms/services/smsclient.h
@@ -0,0 +1,65 @@
+/* *************************************************************************
+ * copyright: (C) 2003 Richard Lrkng <nouseforaname@home.se> *
+ * copyright: (C) 2003 Gav Wood <gav@kde.org> *
+ *************************************************************************
+*/
+
+/* *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef SMSCLIENT_H
+#define SMSCLIENT_H
+
+#include "smsservice.h"
+#include "kopetemessage.h"
+
+#include <qobject.h>
+#include <qstringlist.h>
+
+class SMSClientPrefsUI;
+class SMSContact;
+class QListViewItem;
+class KProcess;
+
+class SMSClient : public SMSService
+{
+ Q_OBJECT
+public:
+ SMSClient(Kopete::Account* account);
+ ~SMSClient();
+
+ void send(const Kopete::Message& msg);
+ void setWidgetContainer(QWidget* parent, QGridLayout* container);
+
+ int maxSize();
+ const QString& description();
+
+public slots:
+ void savePreferences();
+
+private slots:
+ void slotReceivedOutput(KProcess*, char *buffer, int buflen);
+ void slotSendFinished(KProcess* p);
+signals:
+ void messageSent(const Kopete::Message &);
+
+private:
+ QWidget* configureWidget(QWidget* parent);
+
+ SMSClientPrefsUI* prefWidget;
+ QStringList providers();
+ QStringList output;
+
+ Kopete::Message m_msg;
+
+ QString m_description;
+} ;
+
+#endif //SMSCLIENT_H
diff --git a/kopete/protocols/sms/services/smsclientprefs.ui b/kopete/protocols/sms/services/smsclientprefs.ui
new file mode 100644
index 00000000..363081e3
--- /dev/null
+++ b/kopete/protocols/sms/services/smsclientprefs.ui
@@ -0,0 +1,135 @@
+<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<class>SMSClientPrefsUI</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>SMSClientPrefsUI</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>375</width>
+ <height>168</height>
+ </rect>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer16</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>321</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel8</cstring>
+ </property>
+ <property name="font">
+ <font>
+ <bold>1</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>SMSClient Settings</string>
+ </property>
+ </widget>
+ <widget class="Line">
+ <property name="name">
+ <cstring>line14</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout13</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>SMSClient &amp;program:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>program</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>textLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>Pro&amp;vider:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>provider</cstring>
+ </property>
+ </widget>
+ <widget class="KURLRequester" row="0" column="1">
+ <property name="name">
+ <cstring>program</cstring>
+ </property>
+ </widget>
+ <widget class="KURLRequester" row="1" column="1">
+ <property name="name">
+ <cstring>configDir</cstring>
+ </property>
+ </widget>
+ <widget class="QComboBox" row="2" column="1">
+ <property name="name">
+ <cstring>provider</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>SMSClient &amp;config path:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>configDir</cstring>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </vbox>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>kurlrequester.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kurlrequester.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+</includehints>
+</UI>
diff --git a/kopete/protocols/sms/services/smssend.cpp b/kopete/protocols/sms/services/smssend.cpp
new file mode 100644
index 00000000..f3ea258c
--- /dev/null
+++ b/kopete/protocols/sms/services/smssend.cpp
@@ -0,0 +1,254 @@
+/* *************************************************************************
+ * copyright: (C) 2003 Richard L�k�g <nouseforaname@home.se> *
+ * copyright: (C) 2003 Gav Wood <gav@kde.org> *
+ *************************************************************************
+*/
+
+/* *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#include <qcombobox.h>
+#include <qvgroupbox.h>
+#include <qlayout.h>
+#include <qlabel.h>
+#include <qtooltip.h>
+
+#include <kconfigbase.h>
+#include <klineedit.h>
+#include <klocale.h>
+#include <kurlrequester.h>
+#include <kmessagebox.h>
+#include <kdebug.h>
+
+#include "kopeteaccount.h"
+#include "kopeteuiglobal.h"
+
+#include "smssend.h"
+#include "smssendprefs.h"
+#include "smssendprovider.h"
+#include "smsprotocol.h"
+
+SMSSend::SMSSend(Kopete::Account* account)
+ : SMSService(account)
+{
+ kdWarning( 14160 ) << k_funcinfo << " this = " << this << endl;
+ prefWidget = 0L;
+ m_provider = 0L;
+}
+
+SMSSend::~SMSSend()
+{
+}
+
+void SMSSend::send(const Kopete::Message& msg)
+{
+ kdWarning( 14160 ) << k_funcinfo << "m_account = " << m_account << " (should be non-zero!!)" << endl;
+ QString provider = m_account->configGroup()->readEntry("SMSSend:ProviderName", QString::null);
+
+ if (provider.length() < 1)
+ {
+ KMessageBox::error(Kopete::UI::Global::mainWidget(), i18n("No provider configured."), i18n("Could Not Send Message"));
+ return;
+ }
+
+ QString prefix = m_account->configGroup()->readEntry("SMSSend:Prefix", QString::null);
+ if (prefix.isNull())
+ {
+ KMessageBox::error(Kopete::UI::Global::mainWidget(), i18n("No prefix set for SMSSend, please change it in the configuration dialog."), i18n("No Prefix"));
+ return;
+ }
+
+ m_provider = new SMSSendProvider(provider, prefix, m_account, this);
+
+ QObject::connect( m_provider, SIGNAL(messageSent(const Kopete::Message &)), this, SIGNAL(messageSent(const Kopete::Message &)));
+ QObject::connect( m_provider, SIGNAL(messageNotSent(const Kopete::Message &, const QString &)), this, SIGNAL(messageNotSent(const Kopete::Message &, const QString &)));
+
+ m_provider->send(msg);
+}
+
+void SMSSend::setWidgetContainer(QWidget* parent, QGridLayout* layout)
+{
+ kdWarning( 14160 ) << k_funcinfo << "ml: " << layout << ", " << "mp: " << parent << endl;
+ m_parent = parent;
+ m_layout = layout;
+
+ // could end up being deleted twice??
+ delete prefWidget;
+ prefWidget = new SMSSendPrefsUI(parent);
+ layout->addMultiCellWidget(prefWidget, 0, 1, 0, 1);
+
+ prefWidget->program->setMode(KFile::Directory);
+
+ QString prefix = QString::null;
+
+ if (m_account)
+ prefix = m_account->configGroup()->readEntry("SMSSend:Prefix", QString::null);
+ if (prefix.isNull())
+ {
+ QDir d("/usr/share/smssend");
+ if (d.exists())
+ {
+ prefix = "/usr";
+ }
+ d = "/usr/local/share/smssend";
+ if (d.exists())
+ {
+ prefix="/usr/local";
+ }
+ else
+ {
+ prefix="/usr";
+ }
+ }
+
+ QObject::connect (prefWidget->program, SIGNAL(textChanged(const QString &)),
+ this, SLOT(loadProviders(const QString&)));
+
+ prefWidget->program->setURL(prefix);
+
+ QObject::connect(prefWidget->provider, SIGNAL(activated(const QString &)),
+ this, SLOT(setOptions(const QString &)));
+
+ prefWidget->show();
+}
+
+void SMSSend::savePreferences()
+{
+ if (prefWidget != 0L && m_account != 0L && m_provider != 0L )
+ {
+ m_account->configGroup()->writeEntry("SMSSend:Prefix", prefWidget->program->url());
+ m_account->configGroup()->writeEntry("SMSSend:ProviderName", prefWidget->provider->currentText());
+ m_provider->save(args);
+ }
+}
+
+void SMSSend::loadProviders(const QString &prefix)
+{
+ kdWarning( 14160 ) << k_funcinfo << "m_account = " << m_account << " (should be ok if zero)" << endl;
+
+ QStringList p;
+
+ prefWidget->provider->clear();
+
+ QDir d(prefix + "/share/smssend");
+ if (!d.exists())
+ {
+ setOptions(QString::null);
+ return;
+ }
+
+ p = d.entryList("*.sms");
+
+ d = QDir::homeDirPath()+"/.smssend/";
+
+ QStringList tmp(d.entryList("*.sms"));
+
+ for (QStringList::Iterator it = tmp.begin(); it != tmp.end(); ++it)
+ p.prepend(*it);
+
+ for (QStringList::iterator it = p.begin(); it != p.end(); ++it)
+ (*it).truncate((*it).length()-4);
+
+ prefWidget->provider->insertStringList(p);
+
+ bool found = false;
+ if (m_account)
+ { QString pName = m_account->configGroup()->readEntry("SMSSend:ProviderName", QString::null);
+ for (int i=0; i < prefWidget->provider->count(); i++)
+ {
+ if (prefWidget->provider->text(i) == pName)
+ {
+ found=true;
+ prefWidget->provider->setCurrentItem(i);
+ setOptions(pName);
+ break;
+ }
+ }
+ }
+ if (!found)
+ setOptions(prefWidget->provider->currentText());
+}
+
+void SMSSend::setOptions(const QString& name)
+{
+ kdWarning( 14160 ) << k_funcinfo << "m_account = " << m_account << " (should be ok if zero!!)" << endl;
+ if(!prefWidget) return; // sanity check
+
+ prefWidget->providerLabel->setText(i18n("%1 Settings").arg(name));
+
+ labels.setAutoDelete(true);
+ labels.clear();
+ args.setAutoDelete(true);
+ args.clear();
+
+ if (m_provider) delete m_provider;
+ m_provider = new SMSSendProvider(name, prefWidget->program->url(), m_account, this);
+
+ for (int i=0; i < m_provider->count(); i++)
+ {
+ if (!m_provider->name(i).isNull())
+ {
+ QLabel *l = new QLabel(m_parent);
+ l->setText("&" + m_provider->name(i) + ":");
+ QToolTip::add(l, m_provider->description(i));
+ m_layout->addWidget(l, i+2, 0);
+ KLineEdit *e = new KLineEdit(m_parent);
+ e->setText(m_provider->value(i));
+ m_layout->addWidget(e, i+2, 1);
+ args.append(e);
+ labels.append(l);
+ l->setBuddy(e);
+ if(m_provider->isHidden(i))
+ e->setEchoMode(QLineEdit::Password);
+ e->show();
+ l->show();
+ }
+ }
+}
+void SMSSend::setAccount(Kopete::Account* account)
+{
+ m_provider->setAccount(account);
+ SMSService::setAccount(account);
+}
+
+int SMSSend::maxSize()
+{
+ kdWarning( 14160 ) << k_funcinfo << "m_account = " << m_account << " (should be non-zero!!)" << endl;
+
+ QString pName = m_account->configGroup()->readEntry("SMSSend:ProviderName", QString::null);
+ if (pName.length() < 1)
+ return 160;
+ QString prefix = m_account->configGroup()->readEntry("SMSSend:Prefix", QString::null);
+ if (prefix.isNull())
+ prefix = "/usr";
+ // quick sanity check
+ if (m_provider) delete m_provider;
+ m_provider = new SMSSendProvider(pName, prefix, m_account, this);
+ return m_provider->maxSize();
+}
+
+const QString& SMSSend::description()
+{
+ QString url = "http://zekiller.skytech.org/smssend_en.php";
+ m_description = i18n("<qt>SMSSend is a program for sending SMS through gateways on the web. It can be found on <a href=\"%1\">%2</a></qt>").arg(url).arg(url);
+ return m_description;
+}
+
+
+#include "smssend.moc"
+/*
+ * Local variables:
+ * c-indentation-style: k&r
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
+// vim: set noet ts=4 sts=4 sw=4:
+
diff --git a/kopete/protocols/sms/services/smssend.h b/kopete/protocols/sms/services/smssend.h
new file mode 100644
index 00000000..556a21ea
--- /dev/null
+++ b/kopete/protocols/sms/services/smssend.h
@@ -0,0 +1,66 @@
+/* *************************************************************************
+ * copyright: (C) 2003 Richard Lrkng <nouseforaname@home.se> *
+ * copyright: (C) 2003 Gav Wood <gav@kde.org> *
+ *************************************************************************
+*/
+
+/* *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef SMSSEND_H
+#define SMSSEND_H
+
+#include <qobject.h>
+#include <qmap.h>
+#include <qlabel.h>
+
+#include <klineedit.h>
+
+#include "smsservice.h"
+
+class SMSSendProvider;
+class SMSSendPrefsUI;
+class QListViewItem;
+class QGridLayout;
+
+class SMSSend : public SMSService
+{
+ Q_OBJECT
+public:
+ SMSSend(Kopete::Account* account);
+ ~SMSSend();
+
+ virtual void setAccount(Kopete::Account* account);
+
+ void send(const Kopete::Message& msg);
+ void setWidgetContainer(QWidget* parent, QGridLayout* container);
+
+ int maxSize();
+ const QString& description();
+
+public slots:
+ void savePreferences();
+
+private slots:
+ void setOptions(const QString& name);
+ void loadProviders(const QString& prefix);
+//signals:
+// void messageSent(const Kopete::Message&);
+
+private:
+ QGridLayout *settingsBoxLayout;
+ SMSSendProvider* m_provider;
+ SMSSendPrefsUI* prefWidget;
+ QPtrList<KLineEdit> args;
+ QPtrList<QLabel> labels;
+ QString m_description;
+} ;
+
+#endif //SMSSEND_H
diff --git a/kopete/protocols/sms/services/smssendprefs.ui b/kopete/protocols/sms/services/smssendprefs.ui
new file mode 100644
index 00000000..faf3a306
--- /dev/null
+++ b/kopete/protocols/sms/services/smssendprefs.ui
@@ -0,0 +1,188 @@
+<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<class>SMSSendPrefsUI</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>SMSSendPrefsUI</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>338</width>
+ <height>195</height>
+ </rect>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer14</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>311</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel7_2</cstring>
+ </property>
+ <property name="font">
+ <font>
+ <bold>1</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>SMSSend Options</string>
+ </property>
+ </widget>
+ <widget class="Line">
+ <property name="name">
+ <cstring>line6_2</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout12</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QComboBox" row="1" column="1">
+ <property name="name">
+ <cstring>provider</cstring>
+ </property>
+ </widget>
+ <widget class="KURLRequester" row="0" column="1">
+ <property name="name">
+ <cstring>program</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>4</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>4</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Pro&amp;vider:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>provider</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>4</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>SMSSend prefi&amp;x:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>program</cstring>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer15</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>351</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>providerLabel</cstring>
+ </property>
+ <property name="font">
+ <font>
+ <bold>1</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>Provider Options</string>
+ </property>
+ </widget>
+ <widget class="Line">
+ <property name="name">
+ <cstring>line6</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ </vbox>
+</widget>
+<tabstops>
+ <tabstop>program</tabstop>
+ <tabstop>provider</tabstop>
+</tabstops>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>kurlrequester.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+</includehints>
+</UI>
diff --git a/kopete/protocols/sms/services/smssendprovider.cpp b/kopete/protocols/sms/services/smssendprovider.cpp
new file mode 100644
index 00000000..82827aab
--- /dev/null
+++ b/kopete/protocols/sms/services/smssendprovider.cpp
@@ -0,0 +1,288 @@
+/* *************************************************************************
+ * copyright: (C) 2003 Richard Lrkng <nouseforaname@home.se> *
+ * copyright: (C) 2003 Gav Wood <gav@kde.org> *
+ *************************************************************************
+*/
+
+/* *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#include <qvaluelist.h>
+#include <qlabel.h>
+#include <qfile.h>
+
+#include <kconfigbase.h>
+#include <kprocess.h>
+#include <klineedit.h>
+#include <kmessagebox.h>
+#include <kdebug.h>
+#include <klocale.h>
+
+#include "kopeteaccount.h"
+#include "kopeteuiglobal.h"
+
+#include "smssendprovider.h"
+#include "smsprotocol.h"
+#include "smscontact.h"
+
+SMSSendProvider::SMSSendProvider(const QString& providerName, const QString& prefixValue, Kopete::Account* account, QObject* parent, const char *name)
+ : QObject( parent, name ), m_account(account)
+{
+ kdWarning( 14160 ) << k_funcinfo << "this = " << this << ", m_account = " << m_account << " (should be ok if zero!!)" << endl;
+
+ provider = providerName;
+ prefix = prefixValue;
+ m_maxSize = 160;
+
+ messagePos = -1;
+ telPos = -1;
+
+ QString file = prefix + "/share/smssend/" + provider + ".sms";
+ QFile f(file);
+ if (f.open(IO_ReadOnly))
+ {
+ QTextStream t(&f);
+ QString group = QString("SMSSend-%1").arg(provider);
+ bool exactNumberMatch = false;
+ QStringList numberWords;
+ numberWords.append("Tel");
+ numberWords.append("Number");
+ numberWords.append("number");
+ numberWords.append("TelNum");
+ numberWords.append("Recipient");
+ numberWords.append("Tel1");
+ numberWords.append("To");
+ numberWords.append("nummer");
+ numberWords.append("telefone");
+ numberWords.append("ToPhone");
+
+ while( !t.eof())
+ {
+ QString s = t.readLine();
+ if( s[0] == '%')
+ {
+ QStringList args = QStringList::split(':',s);
+ QStringList options = QStringList::split(' ', args[0]);
+
+ names.append(options[0].replace(0,1,""));
+
+ bool hidden = false;
+ for(unsigned i = 1; i < options.count(); i++)
+ if(options[i] == "Hidden")
+ { hidden = true;
+ break;
+ }
+ isHiddens.append(hidden);
+
+ // Strip trailing whitespace in the end
+ // and '%' in the beginning
+ args[0] = args[0].simplifyWhiteSpace().mid(1);
+
+ descriptions.append(args[1]);
+ if (m_account)
+ values.append(m_account->configGroup()->readEntry(QString("%1:%2").arg(group).arg(names[names.count()-1]),
+ QString::null));
+ else
+ values.append("");
+
+ if( args[0].contains("Message") || args[0].contains("message")
+ || args[0].contains("message") || args[0].contains("nachricht")
+ || args[0].contains("Msg") || args[0].contains("Mensagem") )
+ {
+ for( unsigned i = 0; i < options.count(); i++)
+ {
+ if (options[i].contains("Size="))
+ {
+ QString option = options[i];
+ option.replace(0,5,"");
+ m_maxSize = option.toInt();
+ }
+ }
+ messagePos = names.count()-1;
+ }
+ else if (!exactNumberMatch)
+ {
+ for (QStringList::Iterator it=numberWords.begin(); it != numberWords.end(); ++it)
+ {
+ if (args[0].contains(*it))
+ {
+ telPos = names.count() - 1;
+ if (args[0] == *it)
+ {
+// kdDebug(14160) << "Exact match for " << args[0] << endl;
+ exactNumberMatch = true;
+ }
+// kdDebug(14160) << "args[0] (" << args[0] << ") contains " << *it << endl;
+ }
+ }
+ }
+ }
+ }
+ }
+ f.close();
+
+ if ( messagePos == -1 || telPos == -1 )
+ {
+ canSend = false;
+ return;
+ }
+
+ canSend = true;
+}
+
+SMSSendProvider::~SMSSendProvider()
+{
+ kdWarning( 14160 ) << k_funcinfo << "this = " << this << endl;
+}
+
+void SMSSendProvider::setAccount(Kopete::Account *account)
+{
+ m_account = account;
+}
+
+const QString& SMSSendProvider::name(int i)
+{
+ if ( telPos == i || messagePos == i)
+ return QString::null;
+ else
+ return names[i];
+}
+
+const QString& SMSSendProvider::value(int i)
+{
+ return values[i];
+}
+
+const QString& SMSSendProvider::description(int i)
+{
+ return descriptions[i];
+}
+
+const bool SMSSendProvider::isHidden(int i)
+{
+ return isHiddens[i];
+}
+
+void SMSSendProvider::save(QPtrList<KLineEdit>& args)
+{
+ kdDebug( 14160 ) << k_funcinfo << "m_account = " << m_account << " (should be non-zero!!)" << endl;
+ if (!m_account) return; // prevent crash in worst case
+
+ QString group = QString("SMSSend-%1").arg(provider);
+ int namesI=0;
+
+ for (unsigned i=0; i < args.count(); i++)
+ {
+ if (telPos == namesI || messagePos == namesI)
+ {
+// kdDebug(14160) << k_funcinfo << "Skipping pos " << namesI << endl;
+ namesI++;
+ if (telPos == namesI || messagePos == namesI)
+ {
+// kdDebug(14160) << k_funcinfo << "Skipping pos " << namesI << endl;
+ namesI++;
+ }
+ }
+
+// kdDebug(14160) << k_funcinfo << "saving " << args.at(i) << " to " << names[namesI] << endl;
+ if (!args.at(i)->text().isEmpty())
+ { values[namesI] = args.at(i)->text();
+ m_account->configGroup()->writeEntry(QString("%1:%2").arg(group).arg(names[namesI]), values[namesI]);
+ }
+ namesI++;
+ }
+}
+
+int SMSSendProvider::count()
+{
+ return names.count();
+}
+
+void SMSSendProvider::send(const Kopete::Message& msg)
+{
+ if ( canSend == false )
+ {
+ if ( messagePos == -1 )
+ {
+ canSend = false;
+ KMessageBox::error(Kopete::UI::Global::mainWidget(), i18n("Could not determine which argument which should contain the message."),
+ i18n("Could Not Send Message"));
+ return;
+ }
+ if ( telPos == -1 )
+ {
+ canSend = false;
+
+ KMessageBox::error(Kopete::UI::Global::mainWidget(), i18n("Could not determine which argument which should contain the number."),
+ i18n("Could Not Send Message"));
+ return;
+ }
+ }
+
+ m_msg = msg;
+
+ QString message = msg.plainBody();
+ QString nr = dynamic_cast<SMSContact *>(msg.to().first())->qualifiedNumber();
+
+ if (canSend = false)
+ return;
+
+ values[messagePos] = message;
+ values[telPos] = nr;
+
+ KProcess* p = new KProcess;
+
+ kdWarning( 14160 ) << "Executing " << QString("%1/bin/smssend").arg(prefix) << " \"" << provider << "\" " << values.join("\" \"") << "\"" << endl;
+
+ *p << QString("%1/bin/smssend").arg(prefix) << provider << values;
+
+ output = "";
+ connect( p, SIGNAL(processExited(KProcess *)), this, SLOT(slotSendFinished(KProcess *)));
+ connect( p, SIGNAL(receivedStdout(KProcess *, char *, int)), this, SLOT(slotReceivedOutput(KProcess *, char *, int)));
+// connect( p, SIGNAL(receivedStderr(KProcess *, char *, int)), this, SLOT(slotReceivedOutput(KProcess *, char *, int)));
+
+ p->start(KProcess::NotifyOnExit, KProcess::AllOutput);
+}
+
+void SMSSendProvider::slotSendFinished(KProcess *p)
+{
+ kdWarning( 14160 ) << k_funcinfo << "this = " << this << ", es = " << p->exitStatus() << ", p = " << p << " (should be non-zero!!)" << endl;
+ if (p->exitStatus() == 0)
+ emit messageSent(m_msg);
+ else
+ emit messageNotSent(m_msg, QString().setLatin1(output));
+
+ p->deleteLater();
+}
+
+void SMSSendProvider::slotReceivedOutput(KProcess *, char *buffer, int buflen)
+{
+// QStringList lines = QStringList::split("\n", QString::fromLocal8Bit(buffer, buflen));
+// for (QStringList::Iterator it = lines.begin(); it != lines.end(); ++it)
+ for(int i = 0; i < buflen; i++)
+ output += buffer[i];
+ kdWarning( 14160 ) << k_funcinfo << " output now = " << output << endl;
+}
+
+int SMSSendProvider::maxSize()
+{
+ return m_maxSize;
+}
+
+#include "smssendprovider.moc"
+/*
+ * Local variables:
+ * c-indentation-style: k&r
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
+// vim: set noet ts=4 sts=4 sw=4:
+
diff --git a/kopete/protocols/sms/services/smssendprovider.h b/kopete/protocols/sms/services/smssendprovider.h
new file mode 100644
index 00000000..8560be15
--- /dev/null
+++ b/kopete/protocols/sms/services/smssendprovider.h
@@ -0,0 +1,82 @@
+/* *************************************************************************
+ * copyright: (C) 2003 Richard Lrkng <nouseforaname@home.se> *
+ * copyright: (C) 2003 Gav Wood <gav@kde.org> *
+ *************************************************************************
+*/
+
+/* *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef SMSSENDPROVIDER_H
+#define SMSSENDPROVIDER_H
+
+#include <qstring.h>
+#include <qstringlist.h>
+#include <qptrlist.h>
+#include <qlabel.h>
+#include <qvaluelist.h>
+
+#include <klineedit.h>
+
+#include "kopetemessage.h"
+
+#include "smsaccount.h"
+
+class KProcess;
+namespace Kopete { class Account; }
+class SMSContact;
+
+class SMSSendProvider : public QObject
+{
+ Q_OBJECT
+public:
+ SMSSendProvider(const QString& providerName, const QString& prefixValue, Kopete::Account* account, QObject* parent = 0, const char* name = 0);
+ ~SMSSendProvider();
+
+ void setAccount(Kopete::Account *account);
+
+ int count();
+ const QString& name(int i);
+ const QString& value(int i);
+ const QString& description(int i);
+ const bool isHidden(int i);
+
+ void save(QPtrList<KLineEdit>& args);
+ void send(const Kopete::Message& msg);
+
+ int maxSize();
+private slots:
+ void slotReceivedOutput(KProcess*, char *buffer, int buflen);
+ void slotSendFinished(KProcess*);
+private:
+ QStringList names;
+ QStringList descriptions;
+ QStringList values;
+ QValueList<bool> isHiddens;
+
+ int messagePos;
+ int telPos;
+ int m_maxSize;
+
+ QString provider;
+ QString prefix;
+ QCString output;
+
+ Kopete::Account* m_account;
+
+ Kopete::Message m_msg;
+
+ bool canSend;
+signals:
+ void messageSent(const Kopete::Message& msg);
+ void messageNotSent(const Kopete::Message& msg, const QString &error);
+} ;
+
+#endif //SMSSENDPROVIDER_H
diff --git a/kopete/protocols/sms/smsaccount.cpp b/kopete/protocols/sms/smsaccount.cpp
new file mode 100644
index 00000000..5a13dca2
--- /dev/null
+++ b/kopete/protocols/sms/smsaccount.cpp
@@ -0,0 +1,202 @@
+/* *************************************************************************
+ * copyright: (C) 2003 Richard L�k�g <nouseforaname@home.se> *
+ * copyright: (C) 2003 Gav Wood <gav@kde.org> *
+ *************************************************************************
+*/
+
+/* *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#undef KDE_NO_COMPAT
+
+#include <kconfigbase.h>
+#include <kaction.h>
+#include <kpopupmenu.h>
+#include <kprocess.h>
+#include <kdebug.h>
+#include <kmessagebox.h>
+#include <klocale.h>
+#include <kopetemetacontact.h>
+#include <kopetecontactlist.h>
+
+#include "kopeteuiglobal.h"
+
+#include "serviceloader.h"
+
+#include "smsaccount.h"
+#include "smsprotocol.h"
+#include "smscontact.h"
+
+SMSAccount::SMSAccount( SMSProtocol *parent, const QString &accountID, const char *name )
+ : Kopete::Account( parent, accountID, name )
+{
+ setMyself( new SMSContact(this, accountID, accountID, Kopete::ContactList::self()->myself()) );
+ loadConfig();
+ myself()->setOnlineStatus( SMSProtocol::protocol()->SMSOffline );
+
+ QString sName = configGroup()->readEntry("ServiceName", QString::null);
+ theService = ServiceLoader::loadService(sName, this);
+
+ if( theService )
+ {
+ QObject::connect (theService, SIGNAL(messageSent(const Kopete::Message &)),
+ this, SLOT(slotSendingSuccess(const Kopete::Message &)));
+ QObject::connect (theService, SIGNAL(messageNotSent(const Kopete::Message &, const QString &)),
+ this, SLOT(slotSendingFailure(const Kopete::Message &, const QString &)));
+ QObject::connect (theService, SIGNAL(connected()), this, SLOT(slotConnected()));
+ QObject::connect (theService, SIGNAL(disconnected()), this, SLOT(slotDisconnected()));
+ }
+
+}
+
+SMSAccount::~SMSAccount()
+{
+ delete theService;
+ theService = NULL;
+}
+
+void SMSAccount::loadConfig()
+{
+ theSubEnable = configGroup()->readBoolEntry("SubEnable", false);
+ theSubCode = configGroup()->readEntry("SubCode", QString::null);
+ theLongMsgAction = (SMSMsgAction)configGroup()->readNumEntry("MsgAction", 0);
+}
+
+void SMSAccount::translateNumber(QString &theNumber)
+{
+ if(theNumber[0] == QChar('0') && theSubEnable)
+ theNumber.replace(0, 1, theSubCode);
+}
+
+const bool SMSAccount::splitNowMsgTooLong(int msgLength)
+{
+ if( theService == NULL )
+ return false;
+
+ int max = theService->maxSize();
+ if(theLongMsgAction == ACT_CANCEL) return false;
+ if(theLongMsgAction == ACT_SPLIT) return true;
+ if(KMessageBox::questionYesNo(Kopete::UI::Global::mainWidget(), i18n("This message is longer than the maximum length (%1). Should it be divided to %2 messages?").arg(max).arg(msgLength / max + 1),
+ i18n("Message Too Long"), i18n("Divide"), i18n("Do Not Divide")) == KMessageBox::Yes)
+ return true;
+ else
+ return false;
+}
+
+void SMSAccount::setAway( bool /*away*/, const QString &)
+{
+}
+
+void SMSAccount::connect(const Kopete::OnlineStatus&)
+{
+ myself()->setOnlineStatus( SMSProtocol::protocol()->SMSConnecting );
+ if( theService )
+ theService->connect();
+}
+
+void SMSAccount::slotConnected()
+{
+ myself()->setOnlineStatus( SMSProtocol::protocol()->SMSOnline );
+ setAllContactsStatus( SMSProtocol::protocol()->SMSOnline );
+}
+
+void SMSAccount::disconnect()
+{
+ if( theService )
+ theService->disconnect();
+}
+
+void SMSAccount::slotDisconnected()
+{
+ myself()->setOnlineStatus( SMSProtocol::protocol()->SMSOffline );
+ setAllContactsStatus( SMSProtocol::protocol()->SMSOffline );
+}
+
+void SMSAccount::slotSendMessage(Kopete::Message &msg)
+{
+ kdWarning( 14160 ) << k_funcinfo << " this = " << this << endl;
+
+ if(theService == 0L)
+ return;
+
+ int msgLength = msg.plainBody().length();
+
+ if( theService->maxSize() == -1 )
+ {
+ theService->send(msg);
+ }
+ else if( theService->maxSize() < msgLength )
+ {
+ if( splitNowMsgTooLong(msgLength) )
+ {
+ for (int i=0; i < msgLength / theService->maxSize() + 1; i++)
+ {
+ QString text = msg.plainBody();
+ text = text.mid( theService->maxSize() * i, theService->maxSize() );
+ Kopete::Message m( msg.from(), msg.to(), text, Kopete::Message::Outbound);
+
+ theService->send(m);
+ }
+ }
+ else
+ slotSendingFailure(msg, i18n("Message too long."));
+ }
+ else
+ {
+ theService->send(msg);
+ }
+
+}
+
+void SMSAccount::slotSendingSuccess(const Kopete::Message &msg)
+{
+ SMSContact* c = dynamic_cast<SMSContact*>(msg.to().first());
+ if( c )
+ c->slotSendingSuccess(msg);
+}
+
+void SMSAccount::slotSendingFailure(const Kopete::Message &msg, const QString &error)
+{
+ SMSContact* c = dynamic_cast<SMSContact*>(msg.to().first());
+ if( c )
+ c->slotSendingFailure(msg, error);
+}
+
+bool SMSAccount::createContact( const QString &contactId,
+ Kopete::MetaContact * parentContact )
+{
+ if (new SMSContact(this, contactId, parentContact->displayName(), parentContact))
+ return true;
+ else
+ return false;
+}
+
+KActionMenu* SMSAccount::actionMenu()
+{
+ KActionMenu *theActionMenu = Kopete::Account::actionMenu();
+ return theActionMenu;
+}
+
+void SMSAccount::setOnlineStatus( const Kopete::OnlineStatus & status , const QString &reason)
+{
+ if ( myself()->onlineStatus().status() == Kopete::OnlineStatus::Offline && status.status() == Kopete::OnlineStatus::Online )
+ connect();
+ 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 );
+}
+
+SMSService* SMSAccount::service()
+{
+ return theService;
+}
+
+#include "smsaccount.moc"
diff --git a/kopete/protocols/sms/smsaccount.h b/kopete/protocols/sms/smsaccount.h
new file mode 100644
index 00000000..2547fe6c
--- /dev/null
+++ b/kopete/protocols/sms/smsaccount.h
@@ -0,0 +1,79 @@
+/* *************************************************************************
+ * copyright: (C) 2003 Richard Lrkng <nouseforaname@home.se> *
+ * copyright: (C) 2003 Gav Wood <gav@kde.org> *
+ *************************************************************************
+*/
+
+/* *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef SMSACCOUNT_H
+#define SMSACCOUNT_H
+
+#include "kopeteaccount.h"
+
+class KActionMenu;
+class SMSProtocol;
+class SMSContact;
+class SMSService;
+class KProcess;
+
+enum SMSMsgAction { ACT_ASK = 0, ACT_CANCEL, ACT_SPLIT };
+
+class SMSAccount : public Kopete::Account
+{
+ Q_OBJECT
+
+public:
+ SMSAccount( SMSProtocol *parent, const QString &accountID, const char *name = 0L );
+ ~SMSAccount();
+
+ virtual KActionMenu* actionMenu(); // Per-protocol actions for the systray and the status bar
+
+ virtual void setAway( bool away, const QString & );
+
+ void translateNumber(QString &theNumber);
+
+ /**
+ * Checks to see if the message should be split or not, in case it is too long.
+ *
+ * Only ever call in case of message being too long - may result in user interaction.
+ */
+ const bool splitNowMsgTooLong(int msgLength);
+
+ SMSService* service();
+
+public slots:
+ void loadConfig();
+ void setOnlineStatus( const Kopete::OnlineStatus& status , const QString &reason = QString::null);
+
+public slots:
+ virtual void connect(const Kopete::OnlineStatus& initial= Kopete::OnlineStatus());
+ virtual void disconnect();
+ virtual void slotSendMessage(Kopete::Message &msg);
+
+protected slots:
+ virtual void slotSendingSuccess(const Kopete::Message &msg);
+ virtual void slotSendingFailure(const Kopete::Message &msg, const QString &error);
+ virtual void slotConnected();
+ virtual void slotDisconnected();
+
+
+protected:
+ bool createContact(const QString &contactId, Kopete::MetaContact *parentContact);
+
+private:
+ bool theSubEnable;
+ QString theSubCode;
+ SMSMsgAction theLongMsgAction;
+ SMSService* theService;
+};
+
+#endif
diff --git a/kopete/protocols/sms/smsaddcontactpage.cpp b/kopete/protocols/sms/smsaddcontactpage.cpp
new file mode 100644
index 00000000..55921b49
--- /dev/null
+++ b/kopete/protocols/sms/smsaddcontactpage.cpp
@@ -0,0 +1,65 @@
+/* *************************************************************************
+ * copyright: (C) 2003 Richard Lrkng <nouseforaname@home.se> *
+ *************************************************************************
+*/
+
+/* *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#include "smsadd.h"
+#include "smsaddcontactpage.h"
+#include "kopeteaccount.h"
+
+#include <qlayout.h>
+#include <qlineedit.h>
+
+
+
+SMSAddContactPage::SMSAddContactPage(QWidget *parent, const char *name )
+ : AddContactPage(parent,name)
+{
+ (new QVBoxLayout(this))->setAutoAdd(true);
+ smsdata = new smsAddUI(this);
+}
+
+SMSAddContactPage::~SMSAddContactPage()
+{
+
+}
+
+bool SMSAddContactPage::apply(Kopete::Account* a, Kopete::MetaContact* m)
+{
+ if ( validateData() )
+ {
+ QString nr = smsdata->addNr->text();
+ QString name = smsdata->addName->text();
+
+ return a->addContact( nr, m, Kopete::Account::ChangeKABC );
+ }
+
+ return false;
+}
+
+
+bool SMSAddContactPage::validateData()
+{
+ return true;
+}
+
+#include "smsaddcontactpage.moc"
+/*
+ * Local variables:
+ * c-indentation-style: k&r
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
+// vim: set noet ts=4 sts=4 sw=4:
+
diff --git a/kopete/protocols/sms/smsaddcontactpage.h b/kopete/protocols/sms/smsaddcontactpage.h
new file mode 100644
index 00000000..37843bc9
--- /dev/null
+++ b/kopete/protocols/sms/smsaddcontactpage.h
@@ -0,0 +1,50 @@
+/* *************************************************************************
+ * copyright: (C) 2003 Richard Lrkng <nouseforaname@home.se> *
+ *************************************************************************
+*/
+
+/* *************************************************************************
+ * *
+ * 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 SMSADDCONTACTPAGE_H
+#define SMSADDCONTACTPAGE_H
+
+#include <qwidget.h>
+#include <addcontactpage.h>
+#include <qlabel.h>
+
+class smsAddUI;
+class SMSProtocol;
+
+class SMSAddContactPage : public AddContactPage
+{
+ Q_OBJECT
+public:
+ SMSAddContactPage(QWidget *parent=0, const char *name=0);
+ ~SMSAddContactPage();
+ smsAddUI *smsdata;
+ virtual bool validateData();
+ virtual bool apply( Kopete::Account*, Kopete::MetaContact* );
+};
+
+
+#endif
+
+
+
+/*
+ * Local variables:
+ * c-indentation-style: k&r
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
+// vim: set noet ts=4 sts=4 sw=4:
+
diff --git a/kopete/protocols/sms/smscontact.cpp b/kopete/protocols/sms/smscontact.cpp
new file mode 100644
index 00000000..d220b380
--- /dev/null
+++ b/kopete/protocols/sms/smscontact.cpp
@@ -0,0 +1,142 @@
+/* *************************************************************************
+ * copyright: (C) 2003 Richard Lrkng <nouseforaname@home.se> *
+ * copyright: (C) 2003 Gav Wood <gav@kde.org> *
+ *************************************************************************
+*/
+
+/* *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#undef KDE_NO_COMPAT
+#include <kconfigbase.h>
+#include <kaction.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+#include "kopetechatsessionmanager.h"
+#include "kopeteaccount.h"
+#include "kopeteuiglobal.h"
+
+#include "smscontact.h"
+#include "smsprotocol.h"
+#include "smsservice.h"
+#include "smsaccount.h"
+#include "smsuserpreferences.h"
+
+SMSContact::SMSContact( Kopete::Account* _account, const QString &phoneNumber,
+ const QString &displayName, Kopete::MetaContact *parent )
+: Kopete::Contact( _account, phoneNumber, parent ), m_phoneNumber( phoneNumber )
+{
+// kdWarning( 14160 ) << k_funcinfo << " this = " << this << ", phone = " << phoneNumber << endl;
+ setNickName( displayName );
+
+ m_msgManager = 0L;
+ m_actionPrefs = 0L;
+
+ if( account()->isConnected() )
+ setOnlineStatus( SMSProtocol::protocol()->SMSOnline );
+}
+
+void SMSContact::slotSendingSuccess(const Kopete::Message &msg)
+{
+ manager(Kopete::Contact::CanCreate)->messageSucceeded();
+ manager(Kopete::Contact::CanCreate)->appendMessage((Kopete::Message &)msg);
+}
+
+void SMSContact::slotSendingFailure(const Kopete::Message &/*msg*/, const QString &error)
+{
+ KMessageBox::detailedError(Kopete::UI::Global::mainWidget(), i18n("Something went wrong when sending message."), error,
+ i18n("Could Not Send Message"));
+// manager()->messageFailed();
+ // TODO: swap for failed as above. show it anyway for now to allow closing of window.
+ manager(Kopete::Contact::CanCreate)->messageSucceeded();
+}
+
+void SMSContact::serialize( QMap<QString, QString> &serializedData,
+ QMap<QString, QString> & /* addressBookData */ )
+{
+ // Contact id and display name are already set for us
+ if (m_phoneNumber != contactId())
+ serializedData[ "contactId" ] = m_phoneNumber;
+}
+
+Kopete::ChatSession* SMSContact::manager( Kopete::Contact::CanCreateFlags canCreate )
+{
+ if ( m_msgManager || canCreate != Kopete::Contact::CanCreate )
+ {
+ return m_msgManager;
+ }
+ else
+ {
+ QPtrList<Kopete::Contact> contacts;
+ contacts.append(this);
+ m_msgManager = Kopete::ChatSessionManager::self()->create(account()->myself(), contacts, protocol());
+ connect(m_msgManager, SIGNAL(messageSent(Kopete::Message&, Kopete::ChatSession*)),
+ account(), SLOT(slotSendMessage(Kopete::Message&)));
+ connect(m_msgManager, SIGNAL(destroyed()), this, SLOT(slotChatSessionDestroyed()));
+ return m_msgManager;
+ }
+}
+
+void SMSContact::slotChatSessionDestroyed()
+{
+ m_msgManager = 0L;
+}
+
+
+void SMSContact::slotUserInfo()
+{
+}
+
+void SMSContact::deleteContact()
+{
+ deleteLater();
+}
+
+const QString SMSContact::qualifiedNumber()
+{
+ QString number = m_phoneNumber;
+ dynamic_cast<SMSAccount *>(account())->translateNumber(number);
+ return number;
+}
+
+const QString &SMSContact::phoneNumber()
+{
+ return m_phoneNumber;
+}
+
+void SMSContact::setPhoneNumber( const QString phoneNumber )
+{
+ deleteLater();
+ new SMSContact(account(), phoneNumber, nickName(), metaContact());
+}
+
+QPtrList<KAction>* SMSContact::customContextMenuActions()
+{
+ QPtrList<KAction> *m_actionCollection = new QPtrList<KAction>();
+ if( !m_actionPrefs )
+ m_actionPrefs = new KAction(i18n("&Contact Settings"), 0, this, SLOT(userPrefs()), this, "userPrefs");
+
+ m_actionCollection->append( m_actionPrefs );
+
+ return m_actionCollection;
+}
+
+void SMSContact::userPrefs()
+{
+ SMSUserPreferences* p = new SMSUserPreferences( this );
+ p->show();
+}
+
+#include "smscontact.moc"
+
+// vim: set noet ts=4 sts=4 sw=4:
+
diff --git a/kopete/protocols/sms/smscontact.h b/kopete/protocols/sms/smscontact.h
new file mode 100644
index 00000000..b47d2bd9
--- /dev/null
+++ b/kopete/protocols/sms/smscontact.h
@@ -0,0 +1,74 @@
+/* *************************************************************************
+ * copyright: (C) 2003 Richard Lrkng <nouseforaname@home.se> *
+ * copyright: (C) 2003 Gav Wood <gav@kde.org> *
+ *************************************************************************
+*/
+
+/* *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef SMSCONTACT_H
+#define SMSCONTACT_H
+
+#include "kopetecontact.h"
+#include "kopetemessage.h"
+
+#include <qstring.h>
+
+class SMSAccount;
+namespace Kopete { class ChatSession; }
+namespace Kopete { class MetaContact; }
+
+class KActionCollection;
+class KAction;
+
+class SMSContact : public Kopete::Contact
+{
+ Q_OBJECT
+public:
+ SMSContact( Kopete::Account* _account, const QString &phoneNumber,
+ const QString &displayName, Kopete::MetaContact *parent );
+
+ QPtrList<KAction>* customContextMenuActions();
+
+ const QString &phoneNumber();
+ void setPhoneNumber( const QString phoneNumber );
+ const QString qualifiedNumber();
+
+ /**
+ * Serialize contact
+ */
+ virtual void serialize( QMap<QString, QString> &serializedData,
+ QMap<QString, QString> &addressBookData );
+
+ Kopete::ChatSession* manager( Kopete::Contact::CanCreateFlags canCreate = Kopete::Contact::CanCreate );
+
+public slots:
+ virtual void slotUserInfo();
+ virtual void deleteContact();
+ void slotSendingSuccess(const Kopete::Message &msg);
+ void slotSendingFailure(const Kopete::Message &msg, const QString &error);
+
+private slots:
+ void userPrefs();
+ void slotChatSessionDestroyed();
+
+private:
+ KAction* m_actionPrefs;
+
+ QString m_phoneNumber;
+
+ Kopete::ChatSession* m_msgManager;
+};
+
+#endif
+
+// vim: set noet ts=4 sts=4 sw=4:
+
diff --git a/kopete/protocols/sms/smseditaccountwidget.cpp b/kopete/protocols/sms/smseditaccountwidget.cpp
new file mode 100644
index 00000000..b74c24f4
--- /dev/null
+++ b/kopete/protocols/sms/smseditaccountwidget.cpp
@@ -0,0 +1,147 @@
+/* *************************************************************************
+ * copyright: (C) 2003 Richard Lrkng <nouseforaname@home.se> *
+ * copyright: (C) 2003 Gav Wood <gav@kde.org> *
+ *************************************************************************
+*/
+
+/* *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#include <qvgroupbox.h>
+#include <qlayout.h>
+#include <qcombobox.h>
+#include <qpushbutton.h>
+#include <qlineedit.h>
+#include <qcheckbox.h>
+#include <qradiobutton.h>
+
+#include <kconfigbase.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <krestrictedline.h>
+
+#include "kopeteuiglobal.h"
+
+#include "smseditaccountwidget.h"
+#include "smsactprefs.h"
+#include "serviceloader.h"
+#include "smsprotocol.h"
+#include "smsaccount.h"
+
+SMSEditAccountWidget::SMSEditAccountWidget(SMSProtocol *protocol, Kopete::Account *account, QWidget *parent, const char */*name*/)
+ : QWidget(parent), KopeteEditAccountWidget(account)
+{
+ QVBoxLayout *l = new QVBoxLayout(this, QBoxLayout::Down);
+ preferencesDialog = new smsActPrefsUI(this);
+ l->addWidget(preferencesDialog);
+
+ service = 0L;
+ configWidget = 0L;
+ middleFrameLayout = 0L;
+
+ m_protocol = protocol;
+
+ QString sName;
+ if (account)
+ {
+ preferencesDialog->accountId->setText(account->accountId());
+ //Disable changing the account ID for now
+ //FIXME: Remove this when we can safely change the account ID (Matt)
+ preferencesDialog->accountId->setDisabled(true);
+ sName = account->configGroup()->readEntry("ServiceName", QString::null);
+ preferencesDialog->subEnable->setChecked(account->configGroup()->readBoolEntry("SubEnable", false));
+ preferencesDialog->subCode->setText(account->configGroup()->readEntry("SubCode", QString::null));
+ preferencesDialog->ifMessageTooLong->setCurrentItem(SMSMsgAction(account->configGroup()->readNumEntry("MsgAction", 0)));
+ }
+
+ preferencesDialog->serviceName->insertStringList(ServiceLoader::services());
+
+ connect (preferencesDialog->serviceName, SIGNAL(activated(const QString &)),
+ this, SLOT(setServicePreferences(const QString &)));
+ connect (preferencesDialog->descButton, SIGNAL(clicked()),
+ this, SLOT(showDescription()));
+
+
+ for (int i=0; i < preferencesDialog->serviceName->count(); i++)
+ {
+ if (preferencesDialog->serviceName->text(i) == sName)
+ {
+ preferencesDialog->serviceName->setCurrentItem(i);
+ break;
+ }
+ }
+ setServicePreferences(preferencesDialog->serviceName->currentText());
+}
+
+SMSEditAccountWidget::~SMSEditAccountWidget()
+{
+ delete service;
+}
+
+bool SMSEditAccountWidget::validateData()
+{
+ return true;
+}
+
+Kopete::Account* SMSEditAccountWidget::apply()
+{
+ if (!account())
+ setAccount( new SMSAccount( m_protocol, preferencesDialog->accountId->text() ) );
+
+ if (service)
+ service->setAccount(account());
+
+ KConfigGroup *c = account()->configGroup();
+ c->writeEntry("ServiceName", preferencesDialog->serviceName->currentText());
+ c->writeEntry("SubEnable", preferencesDialog->subEnable->isChecked() ? "true" : "false");
+ c->writeEntry("SubCode", preferencesDialog->subCode->text());
+ c->writeEntry("MsgAction", preferencesDialog->ifMessageTooLong->currentItem());
+
+ emit saved();
+ return account();
+}
+
+void SMSEditAccountWidget::setServicePreferences(const QString& serviceName)
+{
+ delete service;
+ delete configWidget;
+
+ service = ServiceLoader::loadService(serviceName, account());
+
+ if (service == 0L)
+ return;
+
+ connect (this, SIGNAL(saved()), service, SLOT(savePreferences()));
+
+ delete middleFrameLayout;
+ middleFrameLayout = new QGridLayout(preferencesDialog->middleFrame, 1, 2, 0, 6, "middleFrameLayout");
+ service->setWidgetContainer(preferencesDialog->middleFrame, middleFrameLayout);
+}
+
+void SMSEditAccountWidget::showDescription()
+{
+ SMSService* s = ServiceLoader::loadService(preferencesDialog->serviceName->currentText(), 0L);
+
+ QString d = s->description();
+
+ KMessageBox::information(Kopete::UI::Global::mainWidget(), d, i18n("Description"));
+}
+
+#include "smseditaccountwidget.moc"
+
+/*
+ * Local variables:
+ * c-indentation-style: k&r
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
+// vim: set noet ts=4 sts=4 sw=4:
+
diff --git a/kopete/protocols/sms/smseditaccountwidget.h b/kopete/protocols/sms/smseditaccountwidget.h
new file mode 100644
index 00000000..eaf83d42
--- /dev/null
+++ b/kopete/protocols/sms/smseditaccountwidget.h
@@ -0,0 +1,64 @@
+/* *************************************************************************
+ * copyright: (C) 2003 Richard Lrkng <nouseforaname@home.se> *
+ * copyright: (C) 2003 Gav Wood <gav@kde.org> *
+ *************************************************************************
+*/
+
+/* *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef SMSEDITACCOUNTWIDGET_H
+#define SMSEDITACCOUNTWIDGET_H
+
+#include <qwidget.h>
+#include "editaccountwidget.h"
+
+class SMSProtocol;
+class SMSService;
+class smsActPrefsUI;
+namespace Kopete { class Account; }
+class QGridLayout;
+
+class SMSEditAccountWidget : public QWidget, public KopeteEditAccountWidget
+{
+ Q_OBJECT
+public:
+ SMSEditAccountWidget(SMSProtocol *protocol, Kopete::Account *theAccount, QWidget *parent = 0, const char *name = 0);
+ ~SMSEditAccountWidget();
+
+ bool validateData();
+ Kopete::Account* apply();
+public slots:
+ void setServicePreferences(const QString& serviceName);
+ void showDescription();
+protected:
+ smsActPrefsUI *preferencesDialog;
+ QWidget *configWidget;
+ SMSService *service;
+ SMSProtocol *m_protocol;
+ QGridLayout *middleFrameLayout;
+
+signals:
+ void saved();
+};
+
+#endif
+
+
+
+/*
+ * Local variables:
+ * c-indentation-style: k&r
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
+// vim: set noet ts=4 sts=4 sw=4:
+
diff --git a/kopete/protocols/sms/smsprotocol.cpp b/kopete/protocols/sms/smsprotocol.cpp
new file mode 100644
index 00000000..6b6cd838
--- /dev/null
+++ b/kopete/protocols/sms/smsprotocol.cpp
@@ -0,0 +1,97 @@
+/* *************************************************************************
+ * copyright: (C) 2003 Richard Lrkng <nouseforaname@home.se> *
+ * copyright: (C) 2003 Gav Wood <gav@kde.org> *
+ *************************************************************************
+*/
+
+/* *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#include <kgenericfactory.h>
+#include <kdebug.h>
+#include <kconfig.h>
+#include <kmessagebox.h>
+
+#include "kopeteaccountmanager.h"
+#include "kopeteonlinestatusmanager.h"
+#include "smsprotocol.h"
+#include "smseditaccountwidget.h"
+#include "smscontact.h"
+#include "smsaddcontactpage.h"
+#include "smsaccount.h"
+
+typedef KGenericFactory<SMSProtocol> SMSProtocolFactory;
+K_EXPORT_COMPONENT_FACTORY( kopete_sms, SMSProtocolFactory( "kopete_sms" ) )
+
+SMSProtocol* SMSProtocol::s_protocol = 0L;
+
+SMSProtocol::SMSProtocol(QObject *parent, const char *name, const QStringList &/*args*/)
+: Kopete::Protocol( SMSProtocolFactory::instance(), parent, name ),
+ SMSOnline( Kopete::OnlineStatus::Online, 25, this, 0, QString::null, i18n( "Online" ), i18n( "Online" ), Kopete::OnlineStatusManager::Online ),
+ SMSConnecting( Kopete::OnlineStatus::Connecting,2, this, 3, QString::null, i18n( "Connecting" ) ),
+ SMSOffline( Kopete::OnlineStatus::Offline, 0, this, 2, QString::null, i18n( "Offline" ), i18n( "Offline" ), Kopete::OnlineStatusManager::Offline )
+{
+ if (s_protocol)
+ kdWarning( 14160 ) << k_funcinfo << "s_protocol already defined!" << endl;
+ else
+ s_protocol = this;
+
+ addAddressBookField("messaging/sms", Kopete::Plugin::MakeIndexField);
+}
+
+SMSProtocol::~SMSProtocol()
+{
+ s_protocol = 0L;
+}
+
+AddContactPage *SMSProtocol::createAddContactWidget(QWidget *parent, Kopete::Account */*i*/)
+{
+ return new SMSAddContactPage(parent);
+}
+
+KopeteEditAccountWidget* SMSProtocol::createEditAccountWidget(Kopete::Account *account, QWidget *parent)
+{
+ return new SMSEditAccountWidget(this, account, parent);
+}
+
+SMSProtocol* SMSProtocol::protocol()
+{
+ return s_protocol;
+}
+
+Kopete::Contact *SMSProtocol::deserializeContact(Kopete::MetaContact *metaContact,
+ const QMap<QString, QString> &serializedData,
+ const QMap<QString, QString> &/* addressBookData */)
+{
+ QString contactId = serializedData["contactId"];
+ QString accountId = serializedData["accountId"];
+ QString displayName = serializedData["displayName"];
+
+ QDict<Kopete::Account> accounts=Kopete::AccountManager::self()->accounts(this);
+
+ Kopete::Account *account = accounts[accountId];
+ if (!account)
+ {
+ kdDebug(14160) << "Account doesn't exist, skipping" << endl;
+ return 0;
+ }
+
+ return new SMSContact(account, contactId, displayName, metaContact);
+}
+
+Kopete::Account* SMSProtocol::createNewAccount(const QString &accountId)
+{
+ return new SMSAccount(this, accountId);
+}
+
+#include "smsprotocol.moc"
+
+// vim: set noet ts=4 sts=4 sw=4:
+
diff --git a/kopete/protocols/sms/smsprotocol.h b/kopete/protocols/sms/smsprotocol.h
new file mode 100644
index 00000000..1d4aaa40
--- /dev/null
+++ b/kopete/protocols/sms/smsprotocol.h
@@ -0,0 +1,71 @@
+/* *************************************************************************
+ * copyright: (C) 2003 Richard Lrkng <nouseforaname@home.se> *
+ * copyright: (C) 2003 Gav Wood <gav@kde.org> *
+ *************************************************************************
+*/
+
+/* *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef SMSPROTOCOL_H
+#define SMSPROTOCOL_H
+
+#include <qmap.h>
+#include <qmovie.h>
+#include <qpixmap.h>
+#include <qptrdict.h>
+#include <qptrlist.h>
+#include <qstringlist.h>
+
+#include "kopeteprotocol.h"
+#include "kopeteonlinestatus.h"
+#include "kopetecontact.h"
+
+class KAction;
+class KActionMenu;
+
+namespace Kopete { class Contact; }
+namespace Kopete { class MetaContact; }
+namespace Kopete { class Message; }
+namespace Kopete { class ChatSession; }
+class SMSContact;
+
+class SMSProtocol : public Kopete::Protocol
+{
+ Q_OBJECT
+
+public:
+ SMSProtocol(QObject *parent, const char *name, const QStringList &args);
+ ~SMSProtocol();
+
+ static SMSProtocol *protocol();
+
+ /**
+ * Deserialize contact data
+ */
+ virtual Kopete::Contact *deserializeContact(Kopete::MetaContact *metaContact,
+ const QMap<QString, QString> &serializedData, const QMap<QString, QString> &addressBookData );
+
+ virtual AddContactPage *createAddContactWidget(QWidget *parent , Kopete::Account *i);
+ virtual KopeteEditAccountWidget *createEditAccountWidget(Kopete::Account *account, QWidget *parent);
+ virtual Kopete::Account *createNewAccount(const QString &accountId);
+
+ const Kopete::OnlineStatus SMSOnline;
+ const Kopete::OnlineStatus SMSOffline;
+ const Kopete::OnlineStatus SMSConnecting;
+
+private:
+ static SMSProtocol *s_protocol;
+};
+
+#endif
+
+// vim: set noet ts=4 sts=4 sw=4:
+
diff --git a/kopete/protocols/sms/smsservice.cpp b/kopete/protocols/sms/smsservice.cpp
new file mode 100644
index 00000000..81b46533
--- /dev/null
+++ b/kopete/protocols/sms/smsservice.cpp
@@ -0,0 +1,63 @@
+/* *************************************************************************
+ * copyright: (C) 2003 Richard Lrkng <nouseforaname@home.se> *
+ * copyright: (C) 2003 Gav Wood <gav@kde.org> *
+ *************************************************************************
+*/
+
+/* *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#include <qlayout.h>
+
+#include <kdebug.h>
+
+#include "smsservice.h"
+
+SMSService::SMSService(Kopete::Account* account)
+ : QObject(), m_account(account)
+{
+}
+
+SMSService::~SMSService()
+{
+
+}
+
+void SMSService::setAccount(Kopete::Account* account)
+{
+ if(!m_account)
+ m_account = account;
+ if(account)
+ savePreferences();
+}
+
+// The Default impl simply flips a signal back
+void SMSService::connect()
+{
+ emit connected();
+}
+
+// The Default impl simply flips a signal back
+void SMSService::disconnect()
+{
+ emit disconnected();
+}
+
+/*
+ * Local variables:
+ * c-indentation-style: k&r
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
+// vim: set noet ts=4 sts=4 sw=4:
+
+
+#include "smsservice.moc"
diff --git a/kopete/protocols/sms/smsservice.h b/kopete/protocols/sms/smsservice.h
new file mode 100644
index 00000000..f1c04470
--- /dev/null
+++ b/kopete/protocols/sms/smsservice.h
@@ -0,0 +1,83 @@
+/* *************************************************************************
+ * copyright: (C) 2003 Richard Lrkng <nouseforaname@home.se> *
+ * copyright: (C) 2003 Gav Wood <gav@kde.org> *
+ *************************************************************************
+*/
+
+/* *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef SMSSERVICE_H
+#define SMSSERVICE_H
+
+#include <qstring.h>
+#include <qwidget.h>
+#include <qobject.h>
+
+#include "kopetemessage.h"
+
+class SMSContact;
+namespace Kopete { class Account; }
+class QGridLayout;
+class QWidget;
+
+class SMSService : public QObject
+{
+ Q_OBJECT
+public:
+ SMSService(Kopete::Account* account = 0);
+ virtual ~SMSService();
+
+ /**
+ * Reimplement to do extra stuff when the account is dynamically changed
+ * (other than just changing m_account).
+ *
+ * Don't forget to call SMSService::setAccount(...) after you've finished.
+ */
+ virtual void setAccount(Kopete::Account* account);
+
+ /**
+ * Called when the settings widget has a place to be. @param parent is the
+ * settings widget's parent and @param layout is the 2xn grid layout it may
+ * use.
+ */
+ virtual void setWidgetContainer(QWidget* parent, QGridLayout* layout) = 0;
+
+ virtual void send(const Kopete::Message& msg) = 0;
+ virtual int maxSize() = 0;
+ virtual const QString& description() = 0;
+
+public slots:
+ virtual void savePreferences() = 0;
+ virtual void connect();
+ virtual void disconnect();
+
+signals:
+ void messageSent(const Kopete::Message &);
+ void messageNotSent(const Kopete::Message &, const QString &);
+ void connected();
+ void disconnected();
+
+protected:
+ Kopete::Account* m_account;
+ QGridLayout* m_layout;
+ QWidget* m_parent;
+};
+
+#endif //SMSSERVICE_H
+/*
+ * Local variables:
+ * c-indentation-style: k&r
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
+// vim: set noet ts=4 sts=4 sw=4:
+
diff --git a/kopete/protocols/sms/smsuserpreferences.cpp b/kopete/protocols/sms/smsuserpreferences.cpp
new file mode 100644
index 00000000..89677080
--- /dev/null
+++ b/kopete/protocols/sms/smsuserpreferences.cpp
@@ -0,0 +1,63 @@
+/* *************************************************************************
+ * copyright: (C) 2003 Richard Lrkng <nouseforaname@home.se> *
+ * copyright: (C) 2003 Gav Wood <gav@kde.org> *
+ *************************************************************************
+*/
+
+/* *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#include <qlabel.h>
+
+#include <klocale.h>
+#include <klineedit.h>
+
+#include "smsuserpreferences.h"
+#include "smsuserprefs.h"
+#include "smscontact.h"
+
+SMSUserPreferences::SMSUserPreferences( SMSContact* contact )
+ : KDialogBase( 0L, "userPrefs", true, i18n("User Preferences"), Ok|Cancel, Ok, true )
+{
+ m_contact = contact;
+ topWidget = makeVBoxMainWidget();
+ userPrefs = new SMSUserPrefsUI( topWidget );
+
+ userPrefs->telNumber->setText(m_contact->phoneNumber());
+ userPrefs->title->setText(m_contact->nickName());
+}
+
+SMSUserPreferences::~SMSUserPreferences()
+{
+
+}
+
+void SMSUserPreferences::slotOk()
+{
+ if (userPrefs->telNumber->text() != m_contact->phoneNumber())
+ m_contact->setPhoneNumber(userPrefs->telNumber->text());
+ slotCancel();
+}
+
+void SMSUserPreferences::slotCancel()
+{
+ deleteLater();
+}
+
+#include "smsuserpreferences.moc"
+/*
+ * Local variables:
+ * c-indentation-style: k&r
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
+// vim: set noet ts=4 sts=4 sw=4:
+
diff --git a/kopete/protocols/sms/smsuserpreferences.h b/kopete/protocols/sms/smsuserpreferences.h
new file mode 100644
index 00000000..29fb6dd2
--- /dev/null
+++ b/kopete/protocols/sms/smsuserpreferences.h
@@ -0,0 +1,44 @@
+/* *************************************************************************
+ * copyright: (C) 2003 Richard Lrkng <nouseforaname@home.se> *
+ * copyright: (C) 2003 Gav Wood <gav@kde.org> *
+ *************************************************************************
+*/
+
+/* *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef SMSUSERPREFERENCES_H
+#define SMSUSERPREFERENCES_H
+
+#include <kdialogbase.h>
+#include <qvbox.h>
+
+class SMSPreferencesBase;
+class SMSUserPrefsUI;
+class SMSContact;
+
+class SMSUserPreferences : public KDialogBase
+{
+ Q_OBJECT
+public:
+ SMSUserPreferences(SMSContact* contact);
+ ~SMSUserPreferences();
+private:
+ SMSPreferencesBase* prefBase;
+ SMSUserPrefsUI* userPrefs;
+ QVBox* topWidget;
+
+ SMSContact* m_contact;
+public slots:
+ void slotOk();
+ void slotCancel();
+} ;
+
+#endif //SMSUSERPREFERENCES_H
diff --git a/kopete/protocols/sms/ui/Makefile.am b/kopete/protocols/sms/ui/Makefile.am
new file mode 100644
index 00000000..660aa359
--- /dev/null
+++ b/kopete/protocols/sms/ui/Makefile.am
@@ -0,0 +1,8 @@
+METASOURCES = AUTO
+AM_CPPFLAGS = $(KOPETE_INCLUDES) \
+ -I$(srcdir)/.. \
+ $(all_includes)
+
+noinst_LTLIBRARIES = libkopetesmsui.la
+
+libkopetesmsui_la_SOURCES = smsadd.ui smsactprefs.ui smsuserprefs.ui empty.cpp
diff --git a/kopete/protocols/sms/ui/empty.cpp b/kopete/protocols/sms/ui/empty.cpp
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/kopete/protocols/sms/ui/empty.cpp
diff --git a/kopete/protocols/sms/ui/smsactprefs.ui b/kopete/protocols/sms/ui/smsactprefs.ui
new file mode 100644
index 00000000..62e53800
--- /dev/null
+++ b/kopete/protocols/sms/ui/smsactprefs.ui
@@ -0,0 +1,435 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>smsActPrefsUI</class>
+<author>Richard Lärkäng</author>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>smsActPrefsUI</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>465</width>
+ <height>437</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="caption">
+ <string>Account Preferences - SMS</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <widget class="QFrame">
+ <property name="name">
+ <cstring>middleFrame</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Raised</enum>
+ </property>
+ <property name="lineWidth">
+ <number>0</number>
+ </property>
+ </widget>
+ <widget class="QTabWidget">
+ <property name="name">
+ <cstring>tabWidget9</cstring>
+ </property>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>B&amp;asic Setup</string>
+ </attribute>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>groupBox61</cstring>
+ </property>
+ <property name="title">
+ <string>Account Information</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Account name:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>accountId</cstring>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>A unique name for this SMS account.</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>A unique name for this SMS account.</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;SMS delivery service:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>serviceName</cstring>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>The delivery service that you would like to use.</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>The delivery service that you would like to use. Note that you will need to have this software installed prior to using this account.</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="0" column="1">
+ <property name="name">
+ <cstring>accountId</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>A unique name for this SMS account.</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="1" column="1">
+ <property name="name">
+ <cstring>layout35</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QComboBox">
+ <property name="name">
+ <cstring>serviceName</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>The delivery service that you would like to use.</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>The delivery service that you would like to use. Note that you will need to have this software installed prior to using this account.</string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>descButton</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Description</string>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Description of the SMS delivery service.</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Description of the SMS delivery service, including download locations.</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </grid>
+ </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>3</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>To use SMS, you will need an account with a delivery service.</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignTop</set>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer25</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>181</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>A&amp;ccount Preferences</string>
+ </attribute>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>groupBox62</cstring>
+ </property>
+ <property name="title">
+ <string>Messaging Preferences</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout119</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel2_2</cstring>
+ </property>
+ <property name="text">
+ <string>If the message is too &amp;long:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>ifMessageTooLong</cstring>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>What should happen if you type a message that is too long to fit in a single SMS message.</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>What should happen if you type a message that is too long to fit in a single SMS message. You can either choose to break it up into smaller messages automatically, cancel the message from being sent entirely, or have Kopete prompt you each time you enter a message that is too long.</string>
+ </property>
+ </widget>
+ <widget class="QComboBox">
+ <item>
+ <property name="text">
+ <string>Prompt (recommended)</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Break Into Multiple</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Cancel Sending</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>ifMessageTooLong</cstring>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>What should happen if you type a message that is too long to fit in a single SMS message.</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>What should happen if you type a message that is too long to fit in a single SMS message. You can either choose to break it up into smaller messages automatically, cancel the message from being sent entirely, or have Kopete prompt you each time you enter a message that is too long.</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>subEnable</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Enable phone number internationalization</string>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Check if you would like to enable phone number internationalization.</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Check if you would like to enable phone number internationalization. Without this option, you will only be able to use SMS for accounts within your country.</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout56</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel2_3</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Substitute leading &amp;zero with code:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>subCode</cstring>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>What you would like to substitute a leading zero with.</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>What you would like to substitute a leading zero with.</string>
+ </property>
+ </widget>
+ <widget class="KRestrictedLine">
+ <property name="name">
+ <cstring>subCode</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>+</string>
+ </property>
+ <property name="validChars">
+ <string>1234567890+</string>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>What you would like to substitute a leading zero with.</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>What you would like to substitute a leading zero with.</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer27</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>labelStatusMessage</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="alignment">
+ <set>AlignCenter</set>
+ </property>
+ </widget>
+ </vbox>
+</widget>
+<connections>
+ <connection>
+ <sender>subEnable</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>textLabel2_3</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>subEnable</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>subCode</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>tabWidget9</tabstop>
+ <tabstop>accountId</tabstop>
+ <tabstop>serviceName</tabstop>
+ <tabstop>descButton</tabstop>
+ <tabstop>ifMessageTooLong</tabstop>
+ <tabstop>subEnable</tabstop>
+ <tabstop>subCode</tabstop>
+</tabstops>
+<includes>
+ <include location="global" impldecl="in implementation">knuminput.h</include>
+</includes>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>krestrictedline.h</includehint>
+</includehints>
+</UI>
diff --git a/kopete/protocols/sms/ui/smsadd.ui b/kopete/protocols/sms/ui/smsadd.ui
new file mode 100644
index 00000000..0ee71281
--- /dev/null
+++ b/kopete/protocols/sms/ui/smsadd.ui
@@ -0,0 +1,143 @@
+<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<class>smsAddUI</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>smsAddUI</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>397</width>
+ <height>347</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </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>layout35</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout33</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Telephone number:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>addNr</cstring>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>The telephone number of the contact you would like to add.</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>The telephone number of the contact you would like to add. This should be a number with SMS service available.</string>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1_2</cstring>
+ </property>
+ <property name="text">
+ <string>Contact na&amp;me:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>addName</cstring>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>A unique name for this SMS account.</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>A unique name for this SMS account.</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout34</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLineEdit">
+ <property name="name">
+ <cstring>addNr</cstring>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>The telephone number of the contact you would like to add.</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>The telephone number of the contact you would like to add. This should be a number with SMS service available.</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit">
+ <property name="name">
+ <cstring>addName</cstring>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>A unique name for this SMS account.</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>A unique name for this SMS account.</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ </hbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer9</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>31</width>
+ <height>170</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+</widget>
+<tabstops>
+ <tabstop>addNr</tabstop>
+ <tabstop>addName</tabstop>
+</tabstops>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/kopete/protocols/sms/ui/smsuserprefs.ui b/kopete/protocols/sms/ui/smsuserprefs.ui
new file mode 100644
index 00000000..8a912792
--- /dev/null
+++ b/kopete/protocols/sms/ui/smsuserprefs.ui
@@ -0,0 +1,118 @@
+<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<class>SMSUserPrefsUI</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>SMSUserPrefsUI</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>252</width>
+ <height>144</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>title</cstring>
+ </property>
+ <property name="font">
+ <font>
+ <bold>1</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>Some One</string>
+ </property>
+ </widget>
+ <widget class="Line">
+ <property name="name">
+ <cstring>line10</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout11</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Telephone number:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>telNumber</cstring>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>The telephone number of the contact.</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>The telephone number of the contact. This should be a number with SMS service available.</string>
+ </property>
+ </widget>
+ <widget class="KLineEdit">
+ <property name="name">
+ <cstring>telNumber</cstring>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>The telephone number of the contact.</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>The telephone number of the contact. This should be a number with SMS service available.</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer11</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>klineedit.h</includehint>
+</includehints>
+</UI>