summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@suse.com>2012-03-23 11:29:48 +0000
committerMatúš Kukan <matus.kukan@gmail.com>2012-07-17 16:39:46 +0200
commit5372069443044e67f5035e4804267a706ef16377 (patch)
treeee7fa5080fabad93b47d8d4156dc503c86efb384 /sc/source
parentcbe4cb777259643bb8552c8365adbba2fa1602a8 (diff)
tubes: add hooks for send / recv file (untested)
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/ui/collab/collab.cxx37
-rw-r--r--sc/source/ui/collab/sendfunc.cxx44
-rw-r--r--sc/source/ui/inc/collab.hxx12
3 files changed, 85 insertions, 8 deletions
diff --git a/sc/source/ui/collab/collab.cxx b/sc/source/ui/collab/collab.cxx
index 87d6f9340579..fdb1a304b96e 100644
--- a/sc/source/ui/collab/collab.cxx
+++ b/sc/source/ui/collab/collab.cxx
@@ -31,9 +31,11 @@
#include <tubes/conference.hxx>
#include <tubes/contact-list.hxx>
-ScCollaboration::ScCollaboration( const Link& rLink )
+ScCollaboration::ScCollaboration( const Link& rLinkPacket,
+ const Link& rLinkFile )
:
- maLink( rLink),
+ maLinkPacket( rLinkPacket ),
+ maLinkFile( rLinkFile ),
mpAccount( NULL),
mpContact( NULL),
mpManager( NULL)
@@ -51,11 +53,28 @@ ScCollaboration::~ScCollaboration()
}
+void ScCollaboration::receivedFile( rtl::OUString &rFileURL )
+{
+ fprintf( stderr, "file recieved '%s'\n",
+ rtl::OUStringToOString( rFileURL, RTL_TEXTENCODING_UTF8 ).getStr() );
+ if ( maLinkFile.IsSet() )
+ maLinkFile.Call( &rFileURL );
+}
+
+extern "C" {
+ void file_recv_cb( rtl::OUString &localUri, void* pUserData )
+ {
+ ScCollaboration *pCollab = reinterpret_cast<ScCollaboration *>( pUserData );
+ pCollab->receivedFile( localUri );
+ }
+}
+
bool ScCollaboration::initManager()
{
- mpManager = new TeleManager( maLink);
+ mpManager = new TeleManager( maLinkPacket );
bool bOk = mpManager->connect();
mpManager->prepareAccountManager();
+ mpManager->setFileReceivedCallback( file_recv_cb, (void *)this );
return bOk;
}
@@ -97,4 +116,16 @@ bool ScCollaboration::recvPacket( rtl::OString& rString, TeleConference* pConfer
return bOk;
}
+extern "C" {
+ static void file_sent_cb( bool aSuccess, void* /* pUserData */ )
+ {
+ fprintf( stderr, "File send %s\n", aSuccess ? "success" : "failed" );
+ }
+}
+
+void ScCollaboration::sendFile( rtl::OUString &rFileURL )
+{
+ mpManager->sendFile( rFileURL, file_sent_cb, NULL );
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx
index ed089558ee25..afeef96f8780 100644
--- a/sc/source/ui/collab/sendfunc.cxx
+++ b/sc/source/ui/collab/sendfunc.cxx
@@ -37,9 +37,12 @@
#include <tubes/conference.hxx>
// new file send/recv fun ...
+#include <com/sun/star/uno/Sequence.hxx>
#include <unotools/tempfile.hxx>
#include <unotools/localfilehelper.hxx>
#include <comphelper/mediadescriptor.hxx>
+#include <com/sun/star/frame/XLoadable.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/document/XDocumentRecovery.hpp>
namespace css = ::com::sun::star;
@@ -253,6 +256,7 @@ public:
}
DECL_LINK( ReceiverCallback, TeleConference* );
+ DECL_LINK( ReceiveFileCallback, rtl::OUString * );
void RecvMessage( const rtl::OString &rString )
{
@@ -299,6 +303,38 @@ IMPL_LINK( ScDocFuncRecv, ReceiverCallback, TeleConference*, pConference )
return 0;
}
+IMPL_LINK( ScDocFuncRecv, ReceiveFileCallback, rtl::OUString *, pStr )
+{
+ fprintf( stderr, "incoming file '%s'\n",
+ rtl::OUStringToOString( *pStr, RTL_TEXTENCODING_UTF8 ).getStr() );
+
+ css::uno::Sequence < css::beans::PropertyValue > aLoadArgs(5);
+ aLoadArgs[0].Name = rtl::OUString( "URL" );
+ aLoadArgs[0].Value <<= (*pStr);
+ aLoadArgs[1].Name = rtl::OUString( "FilterName" );
+ aLoadArgs[1].Value <<= rtl::OUString( "calc8" );
+ aLoadArgs[2].Name = rtl::OUString( "Referer" );
+ aLoadArgs[2].Value <<= rtl::OUString( "" );
+ // no interaction handler ?
+ aLoadArgs[3].Name = rtl::OUString( "MacroExecutionMode" );
+ aLoadArgs[3].Value <<= sal_Int32( 3 );
+ aLoadArgs[4].Name = rtl::OUString( "UpdateDocMode" );
+ aLoadArgs[4].Value <<= sal_Int32( 2 );
+
+ try
+ {
+ css::uno::Reference < css::frame::XLoadable > xLoad(
+ rDocShell.GetBaseModel(), css::uno::UNO_QUERY_THROW );
+ xLoad->load( aLoadArgs );
+ }
+ catch ( css::uno::Exception& )
+ {
+ fprintf( stderr, "exception when loading !\n" );
+ }
+
+ return 0;
+}
+
class ScDocFuncSend : public ScDocFunc
{
ScDocFuncRecv *mpChain;
@@ -337,7 +373,9 @@ class ScDocFuncSend : public ScDocFunc
fprintf( stderr, "Temp file is '%s'\n",
rtl::OUStringToOString( aFileURL, RTL_TEXTENCODING_UTF8 ).getStr() );
-}
+
+ mpCollab->sendFile( aFileURL );
+ }
public:
// FIXME: really ScDocFunc should be an abstract base, so
@@ -478,7 +516,9 @@ SC_DLLPRIVATE ScDocFunc *ScDocShell::CreateDocFunc()
ScDocFuncRecv* pReceiver = new ScDocFuncRecv( *this, new ScDocFuncDirect( *this ) );
ScDocFuncSend* pSender = new ScDocFuncSend( *this, pReceiver );
bool bOk = true;
- ScCollaboration* pCollab = new ScCollaboration( LINK( pReceiver, ScDocFuncRecv, ReceiverCallback));
+ ScCollaboration* pCollab = new ScCollaboration(
+ LINK( pReceiver, ScDocFuncRecv, ReceiverCallback),
+ LINK( pReceiver, ScDocFuncRecv, ReceiveFileCallback) );
bOk = bOk && pCollab->initManager();
bOk = bOk && pCollab->initAccountContact();
bOk = bOk && pCollab->startCollaboration();
diff --git a/sc/source/ui/inc/collab.hxx b/sc/source/ui/inc/collab.hxx
index 8ef392ff2829..c761e9d214cb 100644
--- a/sc/source/ui/inc/collab.hxx
+++ b/sc/source/ui/inc/collab.hxx
@@ -36,7 +36,7 @@ typedef struct _TpContact TpContact;
typedef struct _TpAccount TpAccount;
class TeleManager;
class TeleConference;
-namespace rtl { class OString; }
+namespace rtl { class OString; class OUString; }
class ScCollaboration
{
@@ -44,8 +44,11 @@ public:
/** @param rLink
Callback when a packet is received, called with TeleConference*
+ @param rLink
+ Callback when a file is received, called with TeleConference*
*/
- ScCollaboration( const Link& rLink );
+ ScCollaboration( const Link& rLinkPacket,
+ const Link& rLinkFile );
~ScCollaboration();
bool initManager();
@@ -53,10 +56,13 @@ public:
bool startCollaboration();
bool sendPacket( const rtl::OString& rString );
bool recvPacket( rtl::OString& rString, TeleConference* pConference );
+ void sendFile( rtl::OUString &rFileURL );
+ void receivedFile( rtl::OUString &rFileURL );
private:
- Link maLink;
+ Link maLinkPacket;
+ Link maLinkFile;
TpAccount* mpAccount;
TpContact* mpContact;
TeleManager* mpManager;