~neon/kdenetwork/trunk

« back to all changes in this revision

Viewing changes to kopete/protocols/yahoo/libkyahoo/sendfiletask.h

  • Committer: uwolfer
  • Date: 2013-06-08 10:12:41 UTC
  • Revision ID: svn-v4:283d02a7-25f6-0310-bc7c-ecb5cbfe19da:trunk/KDE/kdenetwork:1357331
kdenetwork has moved to Git

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
    Kopete Yahoo Protocol
3
 
    Send a file
4
 
 
5
 
    Copyright (c) 2006 André Duffeck <duffeck@kde.org>
6
 
 
7
 
    *************************************************************************
8
 
    *                                                                       *
9
 
    * This library is free software; you can redistribute it and/or         *
10
 
    * modify it under the terms of the GNU Lesser General Public            *
11
 
    * License as published by the Free Software Foundation; either          *
12
 
    * version 2 of the License, or (at your option) any later version.      *
13
 
    *                                                                       *
14
 
    *************************************************************************
15
 
*/
16
 
 
17
 
#ifndef SENDFILETASK_H
18
 
#define SENDFILETASK_H
19
 
 
20
 
#include "task.h"
21
 
#include <kurl.h>
22
 
#include <qfile.h>
23
 
 
24
 
class QString;
25
 
namespace KNetwork{
26
 
        class KStreamSocket;
27
 
}
28
 
 
29
 
/**
30
 
@author André Duffeck
31
 
*/
32
 
class SendFileTask : public Task
33
 
{
34
 
        Q_OBJECT
35
 
public:
36
 
        SendFileTask(Task *parent);
37
 
        ~SendFileTask();
38
 
        
39
 
        virtual void onGo();
40
 
        
41
 
        bool take(Transfer *transfer);
42
 
 
43
 
        void setTarget( const QString &to );
44
 
        void setMessage( const QString &msg );
45
 
        void setFileUrl( KUrl url );
46
 
        void setTransferId( unsigned int transferId );
47
 
 
48
 
signals:
49
 
        void bytesProcessed( unsigned int, unsigned int );
50
 
        void complete( unsigned int );
51
 
        void error( unsigned int, int, const QString & );
52
 
 
53
 
        void declined();
54
 
 
55
 
protected:
56
 
        bool forMe( const Transfer *transfer ) const;
57
 
        void sendFileTransferInfo();
58
 
        void parseFileTransfer( const Transfer *transfer );
59
 
        void parseTransferAccept(const Transfer *transfer);
60
 
 
61
 
        QString newYahooTransferId();
62
 
 
63
 
        /** returns true if things need to be stopped due to file transfer error or completed */
64
 
        bool fillSendBuffer();
65
 
 
66
 
        /** returns true if file transfer completed */ 
67
 
        bool checkTransferEnd();
68
 
 
69
 
private slots:
70
 
        void connectSucceeded();
71
 
        void connectFailed( int );
72
 
        void transmitData();
73
 
        void transmitHeader();
74
 
        void canceled( unsigned int );
75
 
 
76
 
private:
77
 
        QString m_msg;
78
 
        QString m_target;
79
 
        KUrl m_url;
80
 
        QFile m_file;
81
 
        unsigned int m_transferId;
82
 
        unsigned int m_transmitted;
83
 
        KNetwork::KStreamSocket *m_socket;
84
 
 
85
 
        QString m_relayHost;
86
 
        QString m_token;
87
 
        QString m_yahooTransferId;
88
 
 
89
 
        /** buffer containing data to be sent */
90
 
        QByteArray m_buffer;
91
 
        /** position (until m_bufferInPos) of data ready to be sent on the wire */
92
 
        int m_bufferOutPos;
93
 
        /** position where next fills from the file should happen */
94
 
        int m_bufferInPos;
95
 
};
96
 
 
97
 
#endif