tubes: send file when inviting contact to MUC collaboration

- add UUID info to TeleConference
- let SendFile function take argument for contact instead of getting
  contact from the channel info, what couldn't work for MUC channel

Change-Id: I4dc45c084966a030ff4b503e192d452797f0bfdd
This commit is contained in:
Matúš Kukan
2012-07-26 17:56:12 +02:00
parent 4eed899c59
commit df2369657e
7 changed files with 15 additions and 11 deletions

View File

@@ -107,6 +107,8 @@ class TubeContacts : public ModelessDialog
{ {
TpContact* pContact = pAC->mpContact; TpContact* pContact = pAC->mpContact;
pSender->GetConference()->invite( pContact ); pSender->GetConference()->invite( pContact );
pSender->SendFile( pContact, OStringToOUString(
pSender->GetConference()->getUuid(), RTL_TEXTENCODING_UTF8 ) );
} }
} }
} }
@@ -135,7 +137,7 @@ class TubeContacts : public ModelessDialog
{ {
ScDocFuncSend* pSender = EnsureScDocFuncSendInCurrentSfxObjectShell(); ScDocFuncSend* pSender = EnsureScDocFuncSendInCurrentSfxObjectShell();
pSender->SetCollaboration( pConference ); pSender->SetCollaboration( pConference );
pSender->SendFile( OStringToOUString( pSender->SendFile( pContact, OStringToOUString(
pConference->getUuid(), RTL_TEXTENCODING_UTF8 ) ); pConference->getUuid(), RTL_TEXTENCODING_UTF8 ) );
} }
} }

View File

@@ -156,7 +156,7 @@ void ScDocFuncSend::SendMessage( ScChangeOpWriter &rOp )
mpDirect->RecvMessage( rOp.toString() ); mpDirect->RecvMessage( rOp.toString() );
} }
void ScDocFuncSend::SendFile( const rtl::OUString &sUuid ) void ScDocFuncSend::SendFile( TpContact* pContact, const rtl::OUString &sUuid )
{ {
String aTmpPath = utl::TempFile::CreateTempName(); String aTmpPath = utl::TempFile::CreateTempName();
aTmpPath.Append( OUString("_") ); aTmpPath.Append( OUString("_") );
@@ -182,8 +182,8 @@ void ScDocFuncSend::SendFile( const rtl::OUString &sUuid )
fprintf( stderr, "Temp file is '%s'\n", fprintf( stderr, "Temp file is '%s'\n",
rtl::OUStringToOString( aFileURL, RTL_TEXTENCODING_UTF8 ).getStr() ); rtl::OUStringToOString( aFileURL, RTL_TEXTENCODING_UTF8 ).getStr() );
if (mpConference) if (pContact)
mpConference->sendFile( aFileURL, file_sent_cb, NULL ); mpConference->sendFile( pContact, aFileURL, file_sent_cb, NULL );
else else
TeleManager_fileReceived( aFileURL ); TeleManager_fileReceived( aFileURL );
@@ -249,7 +249,7 @@ sal_Bool ScDocFuncSend::SetNormalString( bool& o_rbNumFmtSet, const ScAddress& r
o_rbNumFmtSet = false; o_rbNumFmtSet = false;
if ( rtl::OUString( rText ) == "saveme" ) if ( rtl::OUString( rText ) == "saveme" )
SendFile( rText ); SendFile( NULL, rText );
if ( rtl::OUString( rText ) == "contacts" ) if ( rtl::OUString( rText ) == "contacts" )
tubes::createContacts(); tubes::createContacts();

View File

@@ -15,6 +15,7 @@
#include "cell.hxx" #include "cell.hxx"
#include "docfunc.hxx" #include "docfunc.hxx"
class TeleConference; class TeleConference;
typedef struct _TpContact TpContact;
namespace { namespace {
@@ -236,7 +237,7 @@ public:
void SetCollaboration( TeleConference* pConference ); void SetCollaboration( TeleConference* pConference );
TeleConference* GetConference(); TeleConference* GetConference();
// TODO: I think this could be moved to TeleManager later. // TODO: I think this could be moved to TeleManager later.
void SendFile( const rtl::OUString &rURL ); void SendFile( TpContact* pContact, const rtl::OUString &rURL );
virtual void EnterListAction( sal_uInt16 nNameResId ); virtual void EnterListAction( sal_uInt16 nNameResId );
virtual void EndListAction(); virtual void EndListAction();

View File

@@ -66,7 +66,7 @@ public:
boost::signals2::signal<void (const OString&)> sigPacketReceived; boost::signals2::signal<void (const OString&)> sigPacketReceived;
typedef void (*FileSentCallback)( bool aSuccess, void* pUserData); typedef void (*FileSentCallback)( bool aSuccess, void* pUserData);
TUBES_DLLPUBLIC void sendFile( rtl::OUString &localUri, FileSentCallback pCallback, void* pUserData); TUBES_DLLPUBLIC void sendFile( TpContact* pContact, rtl::OUString &localUri, FileSentCallback pCallback, void* pUserData);
TUBES_DLLPUBLIC const OString& getUuid() const { return msUuid; } TUBES_DLLPUBLIC const OString& getUuid() const { return msUuid; }
// --- following only to be called only by manager's callbacks --- // --- following only to be called only by manager's callbacks ---

View File

@@ -264,7 +264,7 @@ void TestTeleTubes::testSendFile()
/* This has to run after testContactList has run successfully. */ /* This has to run after testContactList has run successfully. */
CPPUNIT_ASSERT( mpAccepterContact != 0); CPPUNIT_ASSERT( mpAccepterContact != 0);
mpConference1->sendFile( maTestConfigIniURL, mpConference1->sendFile( mpAccepterContact, maTestConfigIniURL,
&TestTeleTubes::FileSent, NULL); &TestTeleTubes::FileSent, NULL);
/* Waiting for event: FileSent quits the mainloop */ /* Waiting for event: FileSent quits the mainloop */
g_main_loop_run( mpMainLoop); g_main_loop_run( mpMainLoop);

View File

@@ -510,7 +510,7 @@ static void TeleConference_FTReady( EmpathyFTHandler *handler, GError *error, gp
} }
void TeleConference::sendFile( rtl::OUString &localUri, FileSentCallback pCallback, void* pUserData) void TeleConference::sendFile( TpContact* pContact, rtl::OUString &localUri, FileSentCallback pCallback, void* pUserData)
{ {
INFO_LOGGER( "TeleConference::sendFile"); INFO_LOGGER( "TeleConference::sendFile");
@@ -524,7 +524,7 @@ void TeleConference::sendFile( rtl::OUString &localUri, FileSentCallback pCallba
SendFileRequest *pReq = new SendFileRequest( pCallback, pUserData); SendFileRequest *pReq = new SendFileRequest( pCallback, pUserData);
empathy_ft_handler_new_outgoing( mpAccount, empathy_ft_handler_new_outgoing( mpAccount,
tp_channel_get_target_contact( TP_CHANNEL( mpChannel)), pContact,
pSource, pSource,
0, 0,
TeleConference_FTReady, pReq); TeleConference_FTReady, pReq);

View File

@@ -221,6 +221,7 @@ void TeleManager_TransferDone( EmpathyFTHandler *handler, TpFileTransferChannel
sal_Int32 first = aUri.indexOf('_'); sal_Int32 first = aUri.indexOf('_');
sal_Int32 last = aUri.lastIndexOf('_'); sal_Int32 last = aUri.lastIndexOf('_');
SAL_WARN_IF( first == last, "tubes", "No UUID to associate with the file!" );
if (first != last) if (first != last)
{ {
OString sUuid( OUStringToOString( aUri.copy( first + 1, last - first - 1), OString sUuid( OUStringToOString( aUri.copy( first + 1, last - first - 1),
@@ -600,7 +601,7 @@ TeleConference* TeleManager::startGroupSession( TpAccount *pAccount,
setChannelReadyHandlerInvoked( false); setChannelReadyHandlerInvoked( false);
TeleConference* pConference = new TeleConference( this, NULL, NULL ); TeleConference* pConference = new TeleConference( this, NULL, NULL, aSessionId );
tp_account_channel_request_create_and_handle_channel_async( tp_account_channel_request_create_and_handle_channel_async(
pChannelRequest, NULL, TeleManager_ChannelReadyHandler, pConference); pChannelRequest, NULL, TeleManager_ChannelReadyHandler, pConference);