diff options
| author | Alexander Golubev <fatzer2@gmail.com> | 2025-08-17 21:37:04 +0300 |
|---|---|---|
| committer | Fat-Zer <fatzer2@gmail.com> | 2025-08-21 10:00:17 +0000 |
| commit | 7568cd2b93bfdc23fd580fc50485db833b219a07 (patch) | |
| tree | 978b69a18705820b2998f4d67a3868160cbf9dc7 | |
| parent | 0bf48d928d7a50f6d3c3285ca88014100b828315 (diff) | |
| download | tdenetwork-7568cd2b93bfdc23fd580fc50485db833b219a07.tar.gz tdenetwork-7568cd2b93bfdc23fd580fc50485db833b219a07.zip | |
kopete/sms: fix account manipulation issues
This fixes error message on account creation about inability to load
service with empty name. As well as issue about that settings after
changing them won't apply until restart of kopete.
| -rw-r--r-- | kopete/protocols/sms/smsaccount.cpp | 36 | ||||
| -rw-r--r-- | kopete/protocols/sms/smseditaccountwidget.cpp | 16 |
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(); } |
