summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/sms/smsaccount.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kopete/protocols/sms/smsaccount.cpp')
-rw-r--r--kopete/protocols/sms/smsaccount.cpp36
1 files changed, 21 insertions, 15 deletions
diff --git a/kopete/protocols/sms/smsaccount.cpp b/kopete/protocols/sms/smsaccount.cpp
index e2173ee0..f8e4c7a5 100644
--- a/kopete/protocols/sms/smsaccount.cpp
+++ b/kopete/protocols/sms/smsaccount.cpp
@@ -35,25 +35,11 @@
#include "smscontact.h"
SMSAccount::SMSAccount( SMSProtocol *parent, const TQString &accountID, const char *name )
- : Kopete::Account( parent, accountID, name )
+ : Kopete::Account( parent, accountID, name ), theService(nullptr)
{
setMyself( new SMSContact(this, accountID, accountID, Kopete::ContactList::self()->myself()) );
loadConfig();
myself()->setOnlineStatus( SMSProtocol::protocol()->SMSOffline );
-
- TQString sName = configGroup()->readEntry("ServiceName", TQString());
- theService = ServiceLoader::loadService(sName, this);
-
- if( theService )
- {
- TQObject::connect (theService, TQ_SIGNAL(messageSent(const Kopete::Message &)),
- this, TQ_SLOT(slotSendingSuccess(const Kopete::Message &)));
- TQObject::connect (theService, TQ_SIGNAL(messageNotSent(const Kopete::Message &, const TQString &)),
- this, TQ_SLOT(slotSendingFailure(const Kopete::Message &, const TQString &)));
- TQObject::connect (theService, TQ_SIGNAL(connected()), this, TQ_SLOT(slotConnected()));
- TQObject::connect (theService, TQ_SIGNAL(disconnected()), this, TQ_SLOT(slotDisconnected()));
- }
-
}
SMSAccount::~SMSAccount()
@@ -64,9 +50,29 @@ SMSAccount::~SMSAccount()
void SMSAccount::loadConfig()
{
+ TQString serviceName = configGroup()->readEntry("ServiceName", TQString());
theSubEnable = configGroup()->readBoolEntry("SubEnable", false);
theSubCode = configGroup()->readEntry("SubCode", TQString());
theLongMsgAction = (SMSMsgAction)configGroup()->readNumEntry("MsgAction", 0);
+
+ if( theService && theService->name() != serviceName )
+ {
+ delete theService;
+ theService = nullptr;
+ }
+
+ if( !theService && !serviceName.isEmpty() )
+ theService = ServiceLoader::loadService(serviceName, this);
+
+ if( theService )
+ {
+ TQObject::connect (theService, TQ_SIGNAL(messageSent(const Kopete::Message &)),
+ this, TQ_SLOT(slotSendingSuccess(const Kopete::Message &)));
+ TQObject::connect (theService, TQ_SIGNAL(messageNotSent(const Kopete::Message &, const TQString &)),
+ this, TQ_SLOT(slotSendingFailure(const Kopete::Message &, const TQString &)));
+ TQObject::connect (theService, TQ_SIGNAL(connected()), this, TQ_SLOT(slotConnected()));
+ TQObject::connect (theService, TQ_SIGNAL(disconnected()), this, TQ_SLOT(slotDisconnected()));
+ }
}
void SMSAccount::translateNumber(TQString &theNumber)