/****************************************************************************
**
** DCOP Stub Implementation created by dcopidl2cpp from kmymoney2.kidl
**
** WARNING! All changes made in this file will be lost!
**
*****************************************************************************/

#include "kmymoney2_stub.h"
#include <dcopclient.h>

#include <kdatastream.h>


KMyMoney2App_stub::KMyMoney2App_stub( const TQCString& app, const TQCString& obj )
  : DCOPStub( app, obj )
{
}

KMyMoney2App_stub::KMyMoney2App_stub( DCOPClient* client, const TQCString& app, const TQCString& obj )
  : DCOPStub( client, app, obj )
{
}

KMyMoney2App_stub::KMyMoney2App_stub( const DCOPRef& ref )
  : DCOPStub( ref )
{
}

const TQString KMyMoney2App_stub::filename()
{
    TQString result;
    if ( !dcopClient()  ) {
	setStatus( CallFailed );
	return result;
    }
    TQByteArray data, replyData;
    TQCString replyType;
    if ( dcopClient()->call( app(), obj(), "filename()", data, replyType, replyData ) ) {
	if ( replyType == "TQString" ) {
	    TQDataStream _reply_stream( replyData, IO_ReadOnly );
	    _reply_stream >> result;
	    setStatus( CallSucceeded );
	} else {
	    callFailed();
	}
    } else { 
	callFailed();
    }
    return result;
}

void KMyMoney2App_stub::webConnect( const TQString& arg0, const TQCString& arg1 )
{
    if ( !dcopClient()  ) {
	setStatus( CallFailed );
	return;
    }
    TQByteArray data, replyData;
    TQCString replyType;
    TQDataStream arg( data, IO_WriteOnly );
    arg << arg0;
    arg << arg1;
    if ( dcopClient()->call( app(), obj(), "webConnect(TQString,TQCString)", data, replyType, replyData ) ) {
	setStatus( CallSucceeded );
    } else { 
	callFailed();
    }
}

bool KMyMoney2App_stub::okToWriteFile( const KURL& arg0 )
{
    bool result = false;
    if ( !dcopClient()  ) {
	setStatus( CallFailed );
	return result;
    }
    TQByteArray data, replyData;
    TQCString replyType;
    TQDataStream arg( data, IO_WriteOnly );
    arg << arg0;
    if ( dcopClient()->call( app(), obj(), "okToWriteFile(KURL)", data, replyType, replyData ) ) {
	if ( replyType == "bool" ) {
	    TQDataStream _reply_stream( replyData, IO_ReadOnly );
	    _reply_stream >> result;
	    setStatus( CallSucceeded );
	} else {
	    callFailed();
	}
    } else { 
	callFailed();
    }
    return result;
}


