diff options
author | Olli Salli <ollisal@gmail.com> | 2011-04-29 22:04:06 +0300 |
---|---|---|
committer | Olli Salli <ollisal@gmail.com> | 2011-10-10 19:17:40 +0300 |
commit | 88dbb78644fc51394873e0a18b1f8492bb9002f0 (patch) | |
tree | 6bb19a86d202ab2c5dfadbbdead5f87d55cdcd99 /examples | |
parent | 941a41c29d3983833c6b70cfe04fdc164fb95838 (diff) |
Make the usage of accounts in the roster example similar to the tubes example
Specific improvements:
- You specify the account name as would be reported by mc-tool list, not a full D-Bus object path
- There are helpful messages when one gives an invalid or valid but offline account
Diffstat (limited to 'examples')
-rw-r--r-- | examples/roster/main.cpp | 2 | ||||
-rw-r--r-- | examples/roster/roster-window.cpp | 16 | ||||
-rw-r--r-- | examples/roster/roster-window.h | 2 |
3 files changed, 14 insertions, 6 deletions
diff --git a/examples/roster/main.cpp b/examples/roster/main.cpp index d7a41e76..0ae8158d 100644 --- a/examples/roster/main.cpp +++ b/examples/roster/main.cpp @@ -32,7 +32,7 @@ int main(int argc, char **argv) QApplication app(argc, argv); if (argc < 2) { - qDebug() << "usage: roster account"; + qDebug() << "usage:" << argv[0] << "<account name, as in mc-tool list>"; return 1; } diff --git a/examples/roster/roster-window.cpp b/examples/roster/roster-window.cpp index 3cfc89c8..a219bd83 100644 --- a/examples/roster/roster-window.cpp +++ b/examples/roster/roster-window.cpp @@ -36,7 +36,7 @@ using namespace Tp; -RosterWindow::RosterWindow(const QString &accountPath, QWidget *parent) +RosterWindow::RosterWindow(const QString &accountName, QWidget *parent) : QMainWindow(parent) { setWindowTitle(QLatin1String("Roster")); @@ -51,8 +51,9 @@ RosterWindow::RosterWindow(const QString &accountPath, QWidget *parent) ContactFactoryPtr contactFactory = ContactFactory::create( Contact::FeatureAlias | Contact::FeatureSimplePresence); - mAccount = Account::create(TP_QT4_ACCOUNT_MANAGER_BUS_NAME, accountPath, - connectionFactory, channelFactory, contactFactory); + mAccount = Account::create(TP_QT4_ACCOUNT_MANAGER_BUS_NAME, + TP_QT4_ACCOUNT_OBJECT_PATH_BASE + QLatin1Char('/') + accountName, + connectionFactory, channelFactory, contactFactory); connect(mAccount->becomeReady(Account::FeatureCore), SIGNAL(finished(Tp::PendingOperation *)), SLOT(onAccountReady(Tp::PendingOperation *))); @@ -73,7 +74,9 @@ void RosterWindow::setupGui() void RosterWindow::onAccountReady(Tp::PendingOperation *op) { if (op->isError()) { - qWarning() << "Account cannot become ready"; + qWarning() << "Account cannot become ready - " << + op->errorName() << '-' << op->errorMessage(); + QCoreApplication::exit(1); return; } @@ -81,6 +84,11 @@ void RosterWindow::onAccountReady(Tp::PendingOperation *op) connect(mAccount.data(), SIGNAL(connectionChanged(Tp::ConnectionPtr)), SLOT(onAccountConnectionChanged(Tp::ConnectionPtr))); + + if (mAccount->connection().isNull()) { + qDebug() << "The account given has no Connection. Please set it online to continue."; + } + onAccountConnectionChanged(mAccount->connection()); } diff --git a/examples/roster/roster-window.h b/examples/roster/roster-window.h index e8924b27..f3a5b343 100644 --- a/examples/roster/roster-window.h +++ b/examples/roster/roster-window.h @@ -38,7 +38,7 @@ class RosterWindow : public QMainWindow Q_OBJECT public: - RosterWindow(const QString &accountPath, QWidget *parent = 0); + RosterWindow(const QString &accountName, QWidget *parent = 0); virtual ~RosterWindow(); private Q_SLOTS: |