summaryrefslogtreecommitdiffstats
path: root/ksirc/dccManager.h
blob: 7eb7822bdf5ea1d7e0cdb240f9d8a49a9363c149 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef _DCCMANAGER_H
#define _DCCMANAGER_H

#include <time.h>

#include <tqobject.h>

#include "dccManagerbase.h"
#include "klistview.h"


class dccManager;
class TQSignal;
class TQObject;

class dccItem : public TQObject,
                public KListViewItem
{
Q_OBJECT
  TQ_OBJECT
public:
    enum dcctqStatus {
        dccRecving,
	dccOpen,
	dccWaitOnResume,
	dccResumed,
	dccSentOffer,
	dccGotOffer,
        dccSending,
        dccDone,
        dccCancel,
        dccError
    };

    enum dccType {
        dccGet,
        dccChat,
        dccSend
    };

    dccItem( KListView *, dccManager *, enum dccType, const TQString &file, const TQString &who, enum dcctqStatus, unsigned int size );
    dccItem( KListViewItem *, dccManager *, enum dccType, const TQString &file, const TQString &who, enum dcctqStatus, unsigned int size );
    virtual ~dccItem();

    void changetqStatus(enum dcctqStatus);
    void setReceivedBytes(int bytes);

    void setWhoPostfix(const TQString &post);
    void changeFilename(const TQString &file);
    void changeWho(const TQString &who);

    const TQString who() { return m_who; }
    const TQString file() { return m_file; }
    enum dcctqStatus status() { return m_status; }
    enum dccType type() { return m_type; }
    double getPercent() { return m_percent; }

    void doRename();

signals:
    void statusChanged(TQListViewItem *);
    void itemRenamed(dccItem *, TQString oldNick, TQString oldFile);

protected:
    TQString enumTotqStatus(enum dcctqStatus);

    virtual void okRename ( int col );
    virtual void cancelRename ( int col );

private:

    dccManager *m_manager;
    TQString m_who;
    TQString m_file;
    TQString m_post;
    int m_percent;
    unsigned int m_size;
    enum dcctqStatus m_status;
    const enum dccType m_type;
    time_t m_stime;
    time_t m_lasttime;
};


class dccNew;

class dccManager : public dccManagerbase
{
Q_OBJECT
  TQ_OBJECT

public:
    dccManager( TQWidget *tqparent = 0, const char *name = 0 );
    ~dccManager();

    dccItem *newSendItem(TQString file, TQString who, enum dccItem::dcctqStatus, unsigned int size);
    dccItem *newGetItem(TQString file, TQString who, enum dccItem::dcctqStatus, unsigned int size);
    dccItem *newChatItem(TQString who, enum dccItem::dcctqStatus);

    void doChanged() { emit changed(false, TQString("dcc activity")); };

public slots:
    virtual void kpbNew_clicked();
    virtual void kpbConnect_clicked();
    virtual void kpbResume_clicked();
    virtual void kpbRename_clicked();
    virtual void kpbAbort_clicked();

signals:
    void outputLine(TQCString);
    void changed(bool, TQString);
    virtual void dccConnectClicked(dccItem *);
    virtual void dccResumeClicked(dccItem *);
    virtual void dccRenameClicked(dccItem *);
    virtual void dccAbortClicked(dccItem *);

protected slots:
    virtual void getSelChange(TQListViewItem *);
    virtual void sendSelChange(TQListViewItem *);
    virtual void dccNewAccepted(int type, TQString nick, TQString file);

private:

    KListViewItem *m_getit;
    KListViewItem *m_sendit;
    KListViewItem *m_chatit;

    dccNew *dccNewDialog;
};

#endif