[Libreoffice-commits] .: Branch 'feature/tubes2' - 3 commits - tubes/inc tubes/qa tubes/source

Will Thompson wjt at kemper.freedesktop.org
Thu Mar 22 06:00:44 PDT 2012


 tubes/inc/tubes/conference.hxx |    3 -
 tubes/inc/tubes/manager.hxx    |   10 ++----
 tubes/qa/test_manager.cxx      |   63 +++++++++++++++++++++++++++++++++--------
 tubes/source/conference.cxx    |    6 ---
 tubes/source/manager.cxx       |   12 +++----
 5 files changed, 60 insertions(+), 34 deletions(-)

New commits:
commit b881624cc1225c2c851bfc391ac4647aa2539b8d
Author: Will Thompson <will.thompson at collabora.co.uk>
Date:   Thu Mar 22 12:59:15 2012 +0000

    tubes: make startBuddySession take a TpContact *.
    
    I removed Conference::setTarget() because it's redundant: you can get
    the target from the channel. And maTarget was unused anyway.

diff --git a/tubes/inc/tubes/conference.hxx b/tubes/inc/tubes/conference.hxx
index 8f68333..b9fd366 100644
--- a/tubes/inc/tubes/conference.hxx
+++ b/tubes/inc/tubes/conference.hxx
@@ -71,8 +71,6 @@ public:
     // --- following only to be called only by manager's callbacks ---
     // TODO: make friends instead
 
-    /// "buddy at jabber.example.org" or "room at conference.example.org" or "UUID"
-    void                    setTarget( const rtl::OString& rTarget );
     void                    setChannel( TpChannel* pChannel );
     TpChannel*              getChannel() const  { return mpChannel; }
     bool                    offerTube();
@@ -92,7 +90,6 @@ public:
 
 private:
 
-    rtl::OString            maTarget;
     rtl::OString            maSessionId;
     TeleManager*            mpManager;
     TpChannel*              mpChannel;
diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx
index c704780..10f20ef 100644
--- a/tubes/inc/tubes/manager.hxx
+++ b/tubes/inc/tubes/manager.hxx
@@ -105,15 +105,13 @@ public:
 
     /** Start a session with a buddy.
 
-        @param rAccount
-            The account (JID) to use. This must be a valid JID that has been
-            setup with Empathy or another Telepathy client providing
-            Jabber/XMPP.
+        @param pAccount
+            The account to use. This must be a valid Jabber account.
 
-        @param rBuddy
+        @param pBuddy
             The buddy to be connected. Must be a contact of rAccount.
      */
-    bool                    startBuddySession( TpAccount *pAccount, const rtl::OString& rBuddy );
+    bool                    startBuddySession( TpAccount *pAccount, TpContact *pBuddy);
 
     void                    unregisterConference( TeleConferencePtr pConference );
 
diff --git a/tubes/qa/test_manager.cxx b/tubes/qa/test_manager.cxx
index debfef5..b053652 100644
--- a/tubes/qa/test_manager.cxx
+++ b/tubes/qa/test_manager.cxx
@@ -224,8 +224,10 @@ void TestTeleTubes::testPrepareAccountManager2()
 void TestTeleTubes::testStartBuddySession1()
 {
     TpAccount *pAcc1 = mpManager1->getAccount(maOffererIdentifier);
-    CPPUNIT_ASSERT ( pAcc1 != 0);
-    bool bStarted = mpManager1->startBuddySession( pAcc1, maAccepterIdentifier);
+    CPPUNIT_ASSERT( pAcc1 != 0);
+    /* This has to run after testContactList has run successfully. */
+    CPPUNIT_ASSERT( mpAccepterContact != 0);
+    bool bStarted = mpManager1->startBuddySession( pAcc1, mpAccepterContact);
     CPPUNIT_ASSERT( bStarted == true);
 }
 
diff --git a/tubes/source/conference.cxx b/tubes/source/conference.cxx
index f5875e0..830db5f 100644
--- a/tubes/source/conference.cxx
+++ b/tubes/source/conference.cxx
@@ -231,12 +231,6 @@ TeleConference::~TeleConference()
 }
 
 
-void TeleConference::setTarget( const rtl::OString& rTarget )
-{
-    maTarget = rTarget;
-}
-
-
 void TeleConference::setChannel( TpChannel* pChannel )
 {
     OSL_ENSURE( !mpChannel, "TeleConference::setChannel: already have channel");
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index 96c4b3e..5497435 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -392,7 +392,7 @@ bool TeleManager::startGroupSession( const rtl::OUString& rUConferenceRoom, cons
 
 
 /* TODO: factor out common code with startGroupSession() */
-bool TeleManager::startBuddySession( TpAccount *pAccount, const rtl::OString& rBuddy )
+bool TeleManager::startBuddySession( TpAccount *pAccount, TpContact *pBuddy )
 {
     INFO_LOGGER( "TeleManager::startBuddySession");
 
@@ -404,16 +404,15 @@ bool TeleManager::startBuddySession( TpAccount *pAccount, const rtl::OString& rB
     maConferences.push_back( pConference);
 
     /* TODO: associate the document with this session and conference */
-
-    pConference->setTarget( rBuddy);
-
+    const char *pIdentifier = tp_contact_get_identifier( pBuddy);
     SAL_INFO( "tubes", "TeleManager::startBuddySession: creating channel request from "
-            << tp_account_get_path_suffix( pAccount) << " to " << rBuddy.getStr());
+            << tp_account_get_path_suffix( pAccount)
+            << " to " << pIdentifier);
 
     GHashTable* pRequest = tp_asv_new(
             TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_DBUS_TUBE,
             TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, TP_TYPE_HANDLE, TP_HANDLE_TYPE_CONTACT,
-            TP_PROP_CHANNEL_TARGET_ID, G_TYPE_STRING, rBuddy.getStr(),
+            TP_PROP_CHANNEL_TARGET_ID, G_TYPE_STRING, pIdentifier,
             TP_PROP_CHANNEL_TYPE_DBUS_TUBE_SERVICE_NAME, G_TYPE_STRING, getFullServiceName().getStr(),
             NULL);
 
commit dc9ddbecd8f7e0e0fb4eeec51e211f2e6502964d
Author: Will Thompson <will.thompson at collabora.co.uk>
Date:   Thu Mar 22 12:49:17 2012 +0000

    tubes test: find TpContact* for accepter

diff --git a/tubes/qa/test_manager.cxx b/tubes/qa/test_manager.cxx
index da1b3ec..debfef5 100644
--- a/tubes/qa/test_manager.cxx
+++ b/tubes/qa/test_manager.cxx
@@ -62,6 +62,7 @@ public:
     void testFlushLoops();
     void testDestroyManager1();
     void testDestroyManager2();
+    void testDestroyAccepterContact();
     void testFailAlways();
 
     GMainLoop*                  mpMainLoop;
@@ -82,6 +83,7 @@ public:
     CPPUNIT_TEST( testFlushLoops );
     CPPUNIT_TEST( testDestroyManager1 );
     CPPUNIT_TEST( testDestroyManager2 );
+    CPPUNIT_TEST( testDestroyAccepterContact );
     CPPUNIT_TEST( testFailAlways );     // need failure to display SAL_LOG, comment out for real builds
     CPPUNIT_TEST_SUITE_END();
 
@@ -99,6 +101,8 @@ private:
 static TeleManager* mpManager1 = NULL;
 static TeleManager* mpManager2 = NULL;
 
+static TpContact*   mpAccepterContact = NULL;
+
 static sal_uInt32 nSentPackets = 0;
 
 TestTeleTubes::TestTeleTubes()
@@ -159,18 +163,38 @@ void TestTeleTubes::testContactList()
     pairs = cl.getContacts();
     guint i;
 
-    CPPUNIT_ASSERT( pairs.size() > 0 );
+    /* FIXME: this is racy, because we can't be 100% sure that MC has finished
+     * discovering what we support and passing that on to the connection
+     * manager...
+     */
+
+    /* Both our accounts are meant to be signed in, and they both should be
+     * capable of LibreOffice tubes because this test runs after we register
+     * our handler. */
+    CPPUNIT_ASSERT_MESSAGE(
+        "Make sure both your test accounts are signed in "
+        "and are on each other's contact lists",
+        pairs.size() > 0 );
+    CPPUNIT_ASSERT(!mpAccepterContact);
 
     for (i = 0; i < pairs.size(); i++)
     {
         AccountContactPair pair = pairs[i];
-        g_print ("Account %s; contact %s (%s)\n",
-            tp_account_get_display_name (pair.first),
-            tp_contact_get_alias (pair.second),
-            tp_contact_get_identifier (pair.second));
+
+        /* FIXME: verify that pair.first is the offerer account */
+        if (tp_contact_get_identifier(pair.second) == maAccepterIdentifier) {
+            mpAccepterContact = pair.second;
+            g_object_ref(mpAccepterContact);
+        }
         g_object_unref (pair.first);
         g_object_unref (pair.second);
     }
+
+    CPPUNIT_ASSERT_MESSAGE(
+        "Couldn't find accepter contact. "
+        "Make sure both your test accounts are signed in "
+        "and are on each other's contact lists",
+        mpAccepterContact);
 }
 
 void TestTeleTubes::testSetupManager1()
@@ -271,6 +295,14 @@ void TestTeleTubes::testDestroyManager2()
     mpManager2 = NULL;
 }
 
+void TestTeleTubes::testDestroyAccepterContact()
+{
+    if (mpAccepterContact) {
+        g_object_unref(mpAccepterContact);
+        mpAccepterContact = NULL;
+    }
+}
+
 void TestTeleTubes::testFailAlways()
 {
     CPPUNIT_ASSERT( false);
commit fcbe14778dbd92599c780630f781953ffd4a1427
Author: Will Thompson <will.thompson at collabora.co.uk>
Date:   Thu Mar 22 12:43:59 2012 +0000

    tubes test: store OString identifiers
    
    This will prevent having to convert them in multiple places.

diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx
index 122b959..c704780 100644
--- a/tubes/inc/tubes/manager.hxx
+++ b/tubes/inc/tubes/manager.hxx
@@ -113,7 +113,7 @@ public:
         @param rBuddy
             The buddy to be connected. Must be a contact of rAccount.
      */
-    bool                    startBuddySession( TpAccount *pAccount, const rtl::OUString& rBuddy );
+    bool                    startBuddySession( TpAccount *pAccount, const rtl::OString& rBuddy );
 
     void                    unregisterConference( TeleConferencePtr pConference );
 
diff --git a/tubes/qa/test_manager.cxx b/tubes/qa/test_manager.cxx
index ea5806d..da1b3ec 100644
--- a/tubes/qa/test_manager.cxx
+++ b/tubes/qa/test_manager.cxx
@@ -91,8 +91,8 @@ private:
     rtl::OUString             maTestConfigIniURL;
     rtl::Bootstrap            maTestConfig;
 
-    rtl::OUString             maAcc1;
-    rtl::OUString             maAcc2;
+    rtl::OString              maOffererIdentifier;
+    rtl::OString              maAccepterIdentifier;
 };
 
 // static, not members, so they actually survive cppunit test iteration
@@ -107,10 +107,15 @@ TestTeleTubes::TestTeleTubes()
 {
     TeleManager::addSuffixToNames( "TeleTest");
 
+    rtl::OUString aOffererIdentifier;
     CPPUNIT_ASSERT_MESSAGE( "See README for how to set up test-config.ini",
-        maTestConfig.getFrom("offerer", maAcc1));
+        maTestConfig.getFrom("offerer", aOffererIdentifier));
+    maOffererIdentifier = OUStringToOString( aOffererIdentifier, RTL_TEXTENCODING_UTF8);
+
+    rtl::OUString aAccepterIdentifier;
     CPPUNIT_ASSERT_MESSAGE( "See README for how to set up test-config.ini",
-        maTestConfig.getFrom("accepter", maAcc2));
+        maTestConfig.getFrom("accepter", aAccepterIdentifier));
+    maAccepterIdentifier = OUStringToOString( aAccepterIdentifier, RTL_TEXTENCODING_UTF8);
 }
 
 TestTeleTubes::~TestTeleTubes()
@@ -194,9 +199,9 @@ void TestTeleTubes::testPrepareAccountManager2()
 
 void TestTeleTubes::testStartBuddySession1()
 {
-    TpAccount *pAcc1 = mpManager1->getAccount( OUStringToOString( maAcc1, RTL_TEXTENCODING_UTF8));
+    TpAccount *pAcc1 = mpManager1->getAccount(maOffererIdentifier);
     CPPUNIT_ASSERT ( pAcc1 != 0);
-    bool bStarted = mpManager1->startBuddySession( pAcc1, maAcc2);
+    bool bStarted = mpManager1->startBuddySession( pAcc1, maAccepterIdentifier);
     CPPUNIT_ASSERT( bStarted == true);
 }
 
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index 2e1c696..96c4b3e 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -392,7 +392,7 @@ bool TeleManager::startGroupSession( const rtl::OUString& rUConferenceRoom, cons
 
 
 /* TODO: factor out common code with startGroupSession() */
-bool TeleManager::startBuddySession( TpAccount *pAccount, const rtl::OUString& rBuddy )
+bool TeleManager::startBuddySession( TpAccount *pAccount, const rtl::OString& rBuddy )
 {
     INFO_LOGGER( "TeleManager::startBuddySession");
 
@@ -405,16 +405,15 @@ bool TeleManager::startBuddySession( TpAccount *pAccount, const rtl::OUString& r
 
     /* TODO: associate the document with this session and conference */
 
-    OString aTarget( OUStringToOString( rBuddy, RTL_TEXTENCODING_UTF8));
-    pConference->setTarget( aTarget);
+    pConference->setTarget( rBuddy);
 
     SAL_INFO( "tubes", "TeleManager::startBuddySession: creating channel request from "
-            << tp_account_get_path_suffix( pAccount) << " to " << aTarget.getStr());
+            << tp_account_get_path_suffix( pAccount) << " to " << rBuddy.getStr());
 
     GHashTable* pRequest = tp_asv_new(
             TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_DBUS_TUBE,
             TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, TP_TYPE_HANDLE, TP_HANDLE_TYPE_CONTACT,
-            TP_PROP_CHANNEL_TARGET_ID, G_TYPE_STRING, aTarget.getStr(),
+            TP_PROP_CHANNEL_TARGET_ID, G_TYPE_STRING, rBuddy.getStr(),
             TP_PROP_CHANNEL_TYPE_DBUS_TUBE_SERVICE_NAME, G_TYPE_STRING, getFullServiceName().getStr(),
             NULL);
 


More information about the Libreoffice-commits mailing list