diff options
| author | Alexander Golubev <fatzer2@gmail.com> | 2025-08-17 21:37:04 +0300 |
|---|---|---|
| committer | Alexander Golubev <fatzer2@gmail.com> | 2025-08-21 13:03:19 +0300 |
| commit | 9e16e0eb0365f8bc19afdee2cfab42530e080843 (patch) | |
| tree | 3b8e74c18d7484dc30df3c7668af8686944b4a50 | |
| parent | 009ba79c93d828b9ee633620c1c47f9de6764788 (diff) | |
| download | tdenetwork-9e16e0eb.tar.gz tdenetwork-9e16e0eb.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.
(cherry picked from commit 7568cd2b93bfdc23fd580fc50485db833b219a07)
| -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 eddf3508..34ad48fc 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(); } |
