summaryrefslogtreecommitdiff
path: root/tubes
diff options
context:
space:
mode:
authorMatúš Kukan <matus.kukan@gmail.com>2012-08-04 16:30:55 +0200
committerMatúš Kukan <matus.kukan@gmail.com>2012-08-04 22:51:32 +0200
commit401806233ca0ca25c6124a21fd3c873e219cc3e9 (patch)
tree6ac0f27ad717c9a6027f6fbb0b05960fe5b184f1 /tubes
parent2a26650105507cd700b7e91bd55c8a5f61e7dd7c (diff)
tubes: implement another way for demoing collaboration
This way it affects code ~only internally in tubes/ module. Change-Id: I1fd1fa460d51ad57ae2f6df0adeb5fadfc7a8c95
Diffstat (limited to 'tubes')
-rw-r--r--tubes/inc/tubes/manager.hxx10
-rw-r--r--tubes/source/conference.cxx8
-rw-r--r--tubes/source/contacts.cxx24
-rw-r--r--tubes/source/contacts.hrc1
-rw-r--r--tubes/source/contacts.src6
-rw-r--r--tubes/source/manager.cxx56
6 files changed, 95 insertions, 10 deletions
diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx
index 67f319c5154a..06ff54342596 100644
--- a/tubes/inc/tubes/manager.hxx
+++ b/tubes/inc/tubes/manager.hxx
@@ -94,6 +94,9 @@ public:
*/
ContactList* getContactList() const;
+ /** Start a demo session where all local documents are shared to each other */
+ TeleConference* startDemoSession();
+
/** Start a group session in a MUC.
@param pAccount
@@ -125,6 +128,11 @@ public:
/** Get a conference with current UUID to set a session. */
TUBES_DLLPUBLIC static TeleConference* getConference();
+ static void registerDemoConference( TeleConference* pConference );
+ static void unregisterDemoConference( TeleConference* pConference );
+ /** Broadcast packet to all conferences. Used for demo mode. */
+ static void broadcastPacket( const OString& rPacket );
+
/** True if there has been tube channel received and is still not used. */
TUBES_DLLPUBLIC static bool hasWaitingConference();
static void setCurrentUuid( const OString& rUuid );
@@ -135,7 +143,7 @@ public:
// Only for callbacks.
- void addConference( TeleConference* pConference );
+ static void addConference( TeleConference* pConference );
void setChannelReadyHandlerInvoked( bool b );
bool isChannelReadyHandlerInvoked() const;
void setAccountManagerReadyHandlerInvoked( bool b );
diff --git a/tubes/source/conference.cxx b/tubes/source/conference.cxx
index f024685f04d9..3d1bd0a0cb84 100644
--- a/tubes/source/conference.cxx
+++ b/tubes/source/conference.cxx
@@ -376,6 +376,8 @@ void TeleConference::close()
{
INFO_LOGGER( "TeleConference::close");
+ TeleManager::unregisterDemoConference( this );
+
if (mpChannel)
tp_cli_channel_call_close( TP_CHANNEL( mpChannel), 5000, TeleConference_ChannelCloseHandler, this, NULL, NULL);
else
@@ -415,6 +417,12 @@ bool TeleConference::sendPacket( const OString& rPacket )
{
INFO_LOGGER( "TeleConference::sendPacket");
+ if (!mpChannel && !pImpl->mpTube)
+ {
+ TeleManager::broadcastPacket( rPacket );
+ return true;
+ }
+
OSL_ENSURE( mpManager, "tubes: TeleConference::sendPacket: no TeleManager");
SAL_WARN_IF( !pImpl->mpTube, "tubes", "TeleConference::sendPacket: no tube");
if (!(mpManager && pImpl->mpTube))
diff --git a/tubes/source/contacts.cxx b/tubes/source/contacts.cxx
index 4db911368d0b..62cb7bfe0902 100644
--- a/tubes/source/contacts.cxx
+++ b/tubes/source/contacts.cxx
@@ -62,6 +62,7 @@ ResId TubesResId( sal_uInt32 nId )
class TubeContacts : public ModelessDialog
{
FixedLine maLabel;
+ PushButton maBtnDemo;
PushButton maBtnConnect;
PushButton maBtnGroup;
PushButton maBtnInvite;
@@ -71,6 +72,7 @@ class TubeContacts : public ModelessDialog
TeleManager* mpManager;
Collaboration* mpCollaboration;
+ DECL_LINK( BtnDemoHdl, void * );
DECL_LINK( BtnConnectHdl, void * );
DECL_LINK( BtnGroupHdl, void * );
DECL_LINK( BtnInviteHdl, void * );
@@ -108,6 +110,20 @@ class TubeContacts : public ModelessDialog
SAL_INFO( "sc.tubes", "Could not register client handlers." );
}
+ void StartDemoSession()
+ {
+ TeleConference* pConference = mpManager->startDemoSession();
+ if (!pConference)
+ SAL_WARN( "tubes", "Could not start demo session!" );
+ else
+ {
+ pConference->setCollaboration( mpCollaboration );
+ mpCollaboration->SetCollaboration( pConference );
+ mpCollaboration->SendFile( NULL, OStringToOUString(
+ pConference->getUuid(), RTL_TEXTENCODING_UTF8 ) );
+ }
+ }
+
void StartBuddySession()
{
AccountContact *pAC = NULL;
@@ -157,6 +173,7 @@ public:
TubeContacts( Collaboration* pCollaboration ) :
ModelessDialog( NULL, TubesResId( RID_TUBES_DLG_CONTACTS ) ),
maLabel( this, TubesResId( FL_LABEL ) ),
+ maBtnDemo( this, TubesResId( BTN_DEMO ) ),
maBtnConnect( this, TubesResId( BTN_CONNECT ) ),
maBtnGroup( this, TubesResId( BTN_GROUP ) ),
maBtnInvite( this, TubesResId( BTN_INVITE ) ),
@@ -167,6 +184,7 @@ public:
mpCollaboration( pCollaboration )
{
Hide();
+ maBtnDemo.SetClickHdl( LINK( this, TubeContacts, BtnDemoHdl ) );
maBtnConnect.SetClickHdl( LINK( this, TubeContacts, BtnConnectHdl ) );
maBtnGroup.SetClickHdl( LINK( this, TubeContacts, BtnGroupHdl ) );
maBtnInvite.SetClickHdl( LINK( this, TubeContacts, BtnInviteHdl ) );
@@ -237,6 +255,12 @@ public:
}
};
+IMPL_LINK_NOARG( TubeContacts, BtnDemoHdl )
+{
+ StartDemoSession();
+ return 0;
+}
+
IMPL_LINK_NOARG( TubeContacts, BtnConnectHdl )
{
StartBuddySession();
diff --git a/tubes/source/contacts.hrc b/tubes/source/contacts.hrc
index 84c5c3381c6a..a9e1e0a2721a 100644
--- a/tubes/source/contacts.hrc
+++ b/tubes/source/contacts.hrc
@@ -6,6 +6,7 @@
#define BTN_INVITE 4
#define BTN_LISTEN 5
#define BTN_GROUP 6
+#define BTN_DEMO 7
#define STR_HEADER_ALIAS 20
#define STR_HEADER_NAME 21
diff --git a/tubes/source/contacts.src b/tubes/source/contacts.src
index 0cd386af2bfc..08ad1657d045 100644
--- a/tubes/source/contacts.src
+++ b/tubes/source/contacts.src
@@ -18,6 +18,12 @@ ModelessDialog RID_TUBES_DLG_CONTACTS
Size = MAP_APPFONT ( 198 , 8 ) ;
Text [ en-US ] = "Select a contact to collaborate with" ;
};
+ PushButton BTN_DEMO
+ {
+ Pos = MAP_APPFONT( 8, 212 );
+ Size = MAP_APPFONT( 50 , 10 );
+ Text [ en-US ] = "startDemoSession";
+ };
PushButton BTN_CONNECT
{
Pos = MAP_APPFONT( 70 , 200 );
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index 3a2fc1b4ac11..e07db6397c5c 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -46,6 +46,7 @@
#include <telepathy-glib/telepathy-glib.h>
#include <map>
+#include <set>
namespace css = ::com::sun::star;
@@ -100,6 +101,8 @@ public:
OString msCurrentUUID;
typedef std::map< OString, TeleConference* > MapStringConference;
MapStringConference maAcceptedConferences;
+ typedef std::set< TeleConference* > DemoConferences;
+ DemoConferences maDemoConferences;
TeleManagerImpl();
~TeleManagerImpl();
@@ -218,6 +221,24 @@ TeleConference* TeleManager::getConference()
return pConference;
}
+void TeleManager::registerDemoConference( TeleConference* pConference )
+{
+ pImpl->maDemoConferences.insert( pConference );
+}
+
+void TeleManager::unregisterDemoConference( TeleConference* pConference )
+{
+ pImpl->maDemoConferences.erase( pConference );
+}
+
+void TeleManager::broadcastPacket( const OString& rPacket )
+{
+ INFO_LOGGER_F( "TeleManager::broadcastPacket" );
+ for (TeleManagerImpl::DemoConferences::iterator it = pImpl->maDemoConferences.begin();
+ it != pImpl->maDemoConferences.end(); ++it)
+ (*it)->sigPacketReceived( rPacket );
+}
+
bool TeleManager::hasWaitingConference()
{
return pImpl && !pImpl->msCurrentUUID.isEmpty();
@@ -233,6 +254,23 @@ SAL_DLLPUBLIC_EXPORT void TeleManager_fileReceived( const rtl::OUString &rStr )
{
SAL_INFO( "tubes", "TeleManager_fileReceived: incoming file: " << rStr );
+ sal_Int32 first = rStr.indexOf('_');
+ sal_Int32 last = rStr.lastIndexOf('_');
+ SAL_WARN_IF( first == last, "tubes", "No UUID to associate with the file!" );
+ if (first != last)
+ {
+ OString sUuid( OUStringToOString( rStr.copy( first + 1, last - first - 1),
+ RTL_TEXTENCODING_UTF8));
+ if (sUuid == "demo")
+ {
+ sUuid = TeleManager::createUuid();
+ TeleConference* pConference = new TeleConference( NULL, NULL, NULL, sUuid );
+ TeleManager::addConference( pConference );
+ TeleManager::registerDemoConference( pConference );
+ }
+ TeleManager::setCurrentUuid( sUuid );
+ }
+
css::uno::Reference< css::lang::XMultiServiceFactory > rFactory =
::comphelper::getProcessServiceFactory();
@@ -261,15 +299,6 @@ void TeleManager_TransferDone( EmpathyFTHandler *handler, TpFileTransferChannel
rtl::OUString aUri( uri, strlen( uri), RTL_TEXTENCODING_UTF8);
g_free( uri);
- sal_Int32 first = aUri.indexOf('_');
- sal_Int32 last = aUri.lastIndexOf('_');
- SAL_WARN_IF( first == last, "tubes", "No UUID to associate with the file!" );
- if (first != last)
- {
- OString sUuid( OUStringToOString( aUri.copy( first + 1, last - first - 1),
- RTL_TEXTENCODING_UTF8));
- TeleManager::setCurrentUuid( sUuid );
- }
TeleManager_fileReceived( aUri );
g_object_unref( handler);
@@ -595,6 +624,15 @@ bool TeleManager::registerClients()
return true;
}
+TeleConference* TeleManager::startDemoSession()
+{
+ INFO_LOGGER( "TeleManager::startDemoSession");
+
+ TeleConference* pConference = new TeleConference( NULL, NULL, NULL, "demo" );
+ registerDemoConference( pConference );
+
+ return pConference;
+}
/* TODO: factor out common code with startBuddySession() */
TeleConference* TeleManager::startGroupSession( TpAccount *pAccount,