From b3f48c047cc5999dfe849861049f8d3891fd0a13 Mon Sep 17 00:00:00 2001 From: Elvio Basello Date: Mon, 15 Feb 2010 21:12:06 +0000 Subject: compilation fix git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@3972 17fca916-40b9-46aa-a4ea-0a15b648b75c --- src/modules/objects/class_file.h | 13 +-- src/modules/objects/class_ftp.cpp | 188 ++++++++++++++++++++------------------ src/modules/objects/class_ftp.h | 13 ++- 3 files changed, 110 insertions(+), 104 deletions(-) (limited to 'src/modules') diff --git a/src/modules/objects/class_file.h b/src/modules/objects/class_file.h index fcd6544f6..8c41312be 100644 --- a/src/modules/objects/class_file.h +++ b/src/modules/objects/class_file.h @@ -24,11 +24,10 @@ // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // //============================================================================= -#include "class_widget.h" -#include "kvi_file.h" #include "object_macros.h" - +#include "class_widget.h" +#include "kvi_file.h" class KviKvsObject_file : public KviKvsObject_widget @@ -49,9 +48,9 @@ public: bool size(KviKvsObjectFunctionCall *c); bool atEnd(KviKvsObjectFunctionCall *c); - // int QFile at() const + // int QFile at() const bool where(KviKvsObjectFunctionCall *c); - // void QFile at(int) + // void QFile at(int) bool seek(KviKvsObjectFunctionCall *c); bool putch(KviKvsObjectFunctionCall *c); bool getch(KviKvsObjectFunctionCall *c); @@ -68,10 +67,6 @@ public: bool write(KviKvsObjectFunctionCall *c); bool read(KviKvsObjectFunctionCall *c); - - - - }; #endif // !_CLASS_FILE_H_ diff --git a/src/modules/objects/class_ftp.cpp b/src/modules/objects/class_ftp.cpp index 342cd61b3..25e6b46a3 100644 --- a/src/modules/objects/class_ftp.cpp +++ b/src/modules/objects/class_ftp.cpp @@ -26,8 +26,10 @@ #include "kvi_error.h" #include "class_ftp.h" #include "kvi_locale.h" -#include +#include +#include +#include /* @@ -52,51 +54,50 @@ !fn: $connect(,) Connects to the FTP server host using port port.The command is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by commandStarted() and commandFinished().[br] - !fn:$abort() - Aborts the current command and deletes all scheduled commands. - !fn: $login(,) - Logs in to the FTP server with the username user and the password . - The function returns a unique identifier which is passed by commandStarted() and commandFinished().[br] - !fn: $get(,) - Downloads the file from the server. - !fn: $cd() - Changes the working directory of the server to . - !fn: $list() - Lists the contents of directory dir on the FTP server. - !fn: $commandFinishedEvent(,) - Called by KVIrc when the ftp command identified by id has finished. - error is true if an error occurred during the processing; otherwise error is false. - The default implementation emits the [classfnc]$commandFinished[/classfnc]() signal. - !fn: $listInfoEvent() - This event is triggered for each directory entry found by [classfnc]$list[/classfnc]() command. - The default implementation emits the [classfnc]$listInfo[/classfnc]() signal. - !fn: $dataTransferProgressEvent(,) - This event is triggered in response to a [classfnc]get[/classfnc]() or [classfnc]put[/classfnc]() request to indicate the current progress of the download or upload. - The default implementation emits the [classfnc]$dataTransferProgress[/classfnc]() signal. - @signals: - !sg: $commandFinished(,,) - This signal is emitted by the default implementation of [classfnc]$commandFinishedEvent[/classfnc]() - !sg: $listInfo() - This signal is emitted by the default implementation of [classfnc]$listInfoEvent[/classfnc]() - !sg: $dataTransferProgress(,) - This signal is emitted by the default implementation of [classfnc]$dataTransferProgressEvent[/classfnc]() + !fn:$abort() + Aborts the current command and deletes all scheduled commands. + !fn: $login(,) + Logs in to the FTP server with the username user and the password . + The function returns a unique identifier which is passed by commandStarted() and commandFinished().[br] + !fn: $get(,) + Downloads the file from the server. + !fn: $cd() + Changes the working directory of the server to . + !fn: $list() + Lists the contents of directory dir on the FTP server. + !fn: $commandFinishedEvent(,) + Called by KVIrc when the ftp command identified by id has finished. + error is true if an error occurred during the processing; otherwise error is false. + The default implementation emits the [classfnc]$commandFinished[/classfnc]() signal. + !fn: $listInfoEvent() + This event is triggered for each directory entry found by [classfnc]$list[/classfnc]() command. + The default implementation emits the [classfnc]$listInfo[/classfnc]() signal. + !fn: $dataTransferProgressEvent(,) + This event is triggered in response to a [classfnc]get[/classfnc]() or [classfnc]put[/classfnc]() request to indicate the current progress of the download or upload. + The default implementation emits the [classfnc]$dataTransferProgress[/classfnc]() signal. + @signals: + !sg: $commandFinished(,,) + This signal is emitted by the default implementation of [classfnc]$commandFinishedEvent[/classfnc]() + !sg: $listInfo() + This signal is emitted by the default implementation of [classfnc]$listInfoEvent[/classfnc]() + !sg: $dataTransferProgress(,) + This signal is emitted by the default implementation of [classfnc]$dataTransferProgressEvent[/classfnc]() */ KVSO_BEGIN_REGISTERCLASS(KviKvsObject_ftp,"ftp","object") KVSO_REGISTER_HANDLER(KviKvsObject_ftp,"connect",functionConnect) KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_ftp,abort) - KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_ftp,close) - KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_ftp,close) + KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_ftp,close) + KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_ftp,close) KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_ftp,login) KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_ftp,get) KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_ftp,cd) KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_ftp,list) KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_ftp,commandFinishedEvent) KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_ftp,listInfoEvent) - - KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_ftp,stateChangedEvent) -KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_ftp,dataTransferProgressEvent) - KVSO_END_REGISTERCLASS(KviKvsObject_ftp) + KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_ftp,stateChangedEvent) + KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_ftp,dataTransferProgressEvent) +KVSO_END_REGISTERCLASS(KviKvsObject_ftp) KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_ftp,KviKvsObject) @@ -112,17 +113,17 @@ KVSO_BEGIN_CONSTRUCTOR(KviKvsObject_ftp,KviKvsObject) KVSO_END_CONSTRUCTOR(KviKvsObject_ftp) KVSO_BEGIN_DESTRUCTOR(KviKvsObject_ftp) - QHashIterator t(getDict); - while (t.hasNext()) - { - t.next(); - int key=t.key(); - QFile *pFile=getDict.value(key); - pFile->close(); - delete pFile; - } - getDict.clear(); - delete m_pFtp; + QHashIterator t(getDict); + while (t.hasNext()) + { + t.next(); + int key=t.key(); + QFile *pFile=getDict.value(key); + pFile->close(); + delete pFile; + } + getDict.clear(); + delete m_pFtp; KVSO_END_DESTRUCTOR(KviKvsObject_ftp) //---------------------- @@ -134,8 +135,8 @@ KVSO_CLASS_FUNCTION(ftp,functionConnect) QString szHost; kvs_uint_t uRemotePort; KVSO_PARAMETERS_BEGIN(c) - KVSO_PARAMETER("host",KVS_PT_STRING,0,szHost) - KVSO_PARAMETER("remote_port",KVS_PT_UNSIGNEDINTEGER,KVS_PF_OPTIONAL,uRemotePort) + KVSO_PARAMETER("host",KVS_PT_STRING,0,szHost) + KVSO_PARAMETER("remote_port",KVS_PT_UNSIGNEDINTEGER,KVS_PF_OPTIONAL,uRemotePort) KVSO_PARAMETERS_END(c) if (!uRemotePort) uRemotePort=21; kvs_uint_t id=0; @@ -143,71 +144,78 @@ KVSO_CLASS_FUNCTION(ftp,functionConnect) c->returnValue()->setInteger(id); return true; } + KVSO_CLASS_FUNCTION(ftp,login) { CHECK_INTERNAL_POINTER(m_pFtp) QString szUser,szPass; KVSO_PARAMETERS_BEGIN(c) - KVSO_PARAMETER("user",KVS_PT_STRING,0,szUser) - KVSO_PARAMETER("password",KVS_PT_STRING,0,szPass) + KVSO_PARAMETER("user",KVS_PT_STRING,0,szUser) + KVSO_PARAMETER("password",KVS_PT_STRING,0,szPass) KVSO_PARAMETERS_END(c) int id=m_pFtp->login(szUser, szPass); c->returnValue()->setInteger(id); return true; } + KVSO_CLASS_FUNCTION(ftp,get) { CHECK_INTERNAL_POINTER(m_pFtp) QString szFile,szDest; KVSO_PARAMETERS_BEGIN(c) - KVSO_PARAMETER("remote_filename",KVS_PT_STRING,0,szFile) - KVSO_PARAMETER("local_filename",KVS_PT_STRING,0,szDest) + KVSO_PARAMETER("remote_filename",KVS_PT_STRING,0,szFile) + KVSO_PARAMETER("local_filename",KVS_PT_STRING,0,szDest) KVSO_PARAMETERS_END(c) - QFile *pFile; - pFile=new QFile(szDest); - pFile->open(QIODevice::WriteOnly); + QFile *pFile; + pFile=new QFile(szDest); + pFile->open(QIODevice::WriteOnly); int id=0; - id=m_pFtp->get(szFile,pFile); - getDict[id]=pFile; + id=m_pFtp->get(szFile,pFile); + getDict[id]=pFile; c->returnValue()->setInteger(id); return true; } + KVSO_CLASS_FUNCTION(ftp,cd) { CHECK_INTERNAL_POINTER(m_pFtp) QString szPath; KVSO_PARAMETERS_BEGIN(c) - KVSO_PARAMETER("remote_filename",KVS_PT_STRING,0,szPath) + KVSO_PARAMETER("remote_filename",KVS_PT_STRING,0,szPath) KVSO_PARAMETERS_END(c) int id=m_pFtp->cd(szPath); c->returnValue()->setInteger(id); return true; } + KVSO_CLASS_FUNCTION(ftp,list) { CHECK_INTERNAL_POINTER(m_pFtp) QString szPath; KVSO_PARAMETERS_BEGIN(c) - KVSO_PARAMETER("remote_dir",KVS_PT_STRING,0,szPath) + KVSO_PARAMETER("remote_dir",KVS_PT_STRING,0,szPath) KVSO_PARAMETERS_END(c) int id=m_pFtp->list(szPath); c->returnValue()->setInteger(id); return true; } + KVSO_CLASS_FUNCTION(ftp,abort) { CHECK_INTERNAL_POINTER(m_pFtp) - m_bAbort=true; + m_bAbort=true; m_pFtp->abort(); return true; } + KVSO_CLASS_FUNCTION(ftp,close) { - CHECK_INTERNAL_POINTER(m_pFtp) - m_bAbort=true; - m_pFtp->close(); - return true; + CHECK_INTERNAL_POINTER(m_pFtp) + m_bAbort=true; + m_pFtp->close(); + return true; } + //signals & slots KVSO_CLASS_FUNCTION(ftp,commandFinishedEvent) { @@ -218,29 +226,29 @@ KVSO_CLASS_FUNCTION(ftp,commandFinishedEvent) void KviKvsObject_ftp::slotCommandFinished ( int id, bool error ) { QString status=""; - if (m_bAbort) - { - m_bAbort=false; - QHashIterator t(getDict); - while (t.hasNext()) - { - t.next(); - int key=t.key(); - QFile *pFile=getDict.value(key); - pFile->close(); - delete pFile; - } - getDict.clear(); - return; - } - if (m_pFtp->currentCommand()==QFtp::Get) - { - status="Downloaded"; - QFile *pFile=getDict.value(id); - pFile->close(); - delete pFile; - getDict.remove(id); - } + if (m_bAbort) + { + m_bAbort=false; + QHashIterator t(getDict); + while (t.hasNext()) + { + t.next(); + int key=t.key(); + QFile *pFile=getDict.value(key); + pFile->close(); + delete pFile; + } + getDict.clear(); + return; + } + if (m_pFtp->currentCommand()==QFtp::Get) + { + status="Downloaded"; + QFile *pFile=getDict.value(id); + pFile->close(); + delete pFile; + getDict.remove(id); + } else if (m_pFtp->currentCommand()==QFtp:: ConnectToHost) status="connected"; else if (m_pFtp->currentCommand()==QFtp:: Login) status="logged"; else if (m_pFtp->currentCommand()==QFtp:: Cd) status="entered"; @@ -258,11 +266,13 @@ void KviKvsObject_ftp::slotDataTransferProgress ( qint64 done, qint64 total ) callFunction(this,"dataTransferProgressEvent",0,new KviKvsVariantList( new KviKvsVariant((kvs_int_t) done),new KviKvsVariant((kvs_int_t) total))); } + KVSO_CLASS_FUNCTION(ftp,dataTransferProgressEvent) { emitSignal("dataTransferProgress",c,c->params()); return true; } + void KviKvsObject_ftp::slotDone ( bool ) { } @@ -270,8 +280,8 @@ void KviKvsObject_ftp::slotDone ( bool ) void KviKvsObject_ftp::slotListInfo ( const QUrlInfo & i ) { callFunction(this,"listInfoEvent",0,new KviKvsVariantList(new KviKvsVariant(i.name()))); - } + KVSO_CLASS_FUNCTION(ftp,listInfoEvent) { emitSignal("listInfo",c,c->params()); @@ -298,11 +308,13 @@ void KviKvsObject_ftp::slotStateChanged (int state) callFunction(this,"stateChangedEvent",0,new KviKvsVariantList( new KviKvsVariant(szState))); } + KVSO_CLASS_FUNCTION(ftp,stateChangedEvent) { emitSignal("stateChanged",c,c->params()); return true; } + #ifndef COMPILE_USE_STANDALONE_MOC_SOURCES #include "m_class_ftp.moc" #endif //!COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/modules/objects/class_ftp.h b/src/modules/objects/class_ftp.h index 85c40688b..3f56cf42f 100644 --- a/src/modules/objects/class_ftp.h +++ b/src/modules/objects/class_ftp.h @@ -24,14 +24,13 @@ // //============================================================================= - - - -//=============================================================== #include "object_macros.h" + #include #include +class QHash; + class KviKvsObject_ftp : public KviKvsObject { Q_OBJECT @@ -39,8 +38,8 @@ public: KVSO_DECLARE_OBJECT(KviKvsObject_ftp) protected: QFtp *m_pFtp; - QHash getDict; - bool m_bAbort; + QHash getDict; + bool m_bAbort; protected: bool functionConnect(KviKvsObjectFunctionCall *c); bool get(KviKvsObjectFunctionCall *c); @@ -52,7 +51,7 @@ protected: bool commandFinishedEvent(KviKvsObjectFunctionCall *c); bool stateChangedEvent(KviKvsObjectFunctionCall *c); bool abort(KviKvsObjectFunctionCall *c); - bool close(KviKvsObjectFunctionCall *c); + bool close(KviKvsObjectFunctionCall *c); protected slots: void slotCommandFinished ( int id, bool error ); void slotCommandStarted ( int id ); -- cgit v1.3.1-10-gc9f91