summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kopete/protocols/sms/smsaccount.cpp36
-rw-r--r--kopete/protocols/sms/smseditaccountwidget.cpp16
2 files changed, 34 insertions, 18 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)
diff --git a/kopete/protocols/sms/smseditaccountwidget.cpp b/kopete/protocols/sms/smseditaccountwidget.cpp
index 5994534d..6283c2dd 100644
--- a/kopete/protocols/sms/smseditaccountwidget.cpp
+++ b/kopete/protocols/sms/smseditaccountwidget.cpp
@@ -92,18 +92,28 @@ bool SMSEditAccountWidget::validateData()
Kopete::Account* SMSEditAccountWidget::apply()
{
- if (!account())
- setAccount( new SMSAccount( m_protocol, preferencesDialog->accountId->text() ) );
+ SMSAccount *smsAccount;
+
+ if (account()) {
+ smsAccount = dynamic_cast<SMSAccount*>(account());
+ } else {
+ smsAccount = new SMSAccount( m_protocol,
+ preferencesDialog->accountId->text() );
+ setAccount( smsAccount );
+ }
+ Q_ASSERT( smsAccount );
if (service)
service->setAccount(account());
-
+
TDEConfigGroup *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());
+ smsAccount->loadConfig();
+
emit saved();
return account();
}