-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkio.cpp
105 lines (85 loc) · 2.08 KB
/
kio.cpp
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
#include <kapp.h>
#if QT_VERSION >= 200
#include "kio.h"
extern KApplication *app;
Kio::Kio()
{
iojob = 0;
}
bool Kio::download(QString from, QString to)
{
if (iojob == 0) {
iojob = new KIOJob;
}
connect( iojob, SIGNAL( sigFinished( int ) ),
this, SLOT( slotIOJobFinished( int ) ) );
connect( iojob, SIGNAL( sigError(int, const char *) ),
this, SLOT( slotIOJobError(int, const char *) ) );
iojob->copy( from, to );
printf("Enter...............................\n");
app->enter_loop();
iojob = 0;
return worked;
}
void Kio::slotIOJobFinished( int )
{
printf("Leave FIN...............................\n");
worked = TRUE;
app->exit_loop();
}
void Kio::slotIOJobError( int )
{
printf("Leave ERR...............................\n");
worked = FALSE;
app->exit_loop();
}
Kiod::Kiod()
{
job = new KIOJob;
QObject::connect( job, SIGNAL( sigListEntry( int, const UDSEntry& ) ),
this, SLOT( slotListEntry( int, const UDSEntry& ) ) );
QObject::connect( job, SIGNAL( sigFinished( int ) ),
this, SLOT( slotFinished( int ) ) );
QObject::connect( job, SIGNAL( sigError( int, int, const char* ) ),
this, SLOT( slotError( int, int, const char* ) ) );
}
bool Kiod::listDir(QString url, QString fname)
{
file = new QFile(fname);
if (file->open(IO_WriteOnly)) {
fileT = new QTextStream(file);
job->listDir( url );
app->enter_loop();
file->close();
if (worked)
return TRUE;
else
return FALSE;
} else
return FALSE;
}
void Kiod::slotListEntry( int /*_id*/, const UDSEntry& entry )
{
long size = 0;
QString text;
UDSEntry::const_iterator it = entry.begin();
for ( ; it != entry.end(); it++ ) {
if ( it->m_uds == UDS_SIZE )
size = it->m_long;
else if ( it->m_uds == UDS_NAME )
text = it->m_str.c_str();
}
*fileT << text << "\n" << size << "\n";
}
void Kiod::slotError( int /*_id*/, int _errid, const char* _errortext )
{
// kioErrorDialog( _errid, _errortext );
worked = FALSE;
app->exit_loop();
}
void Kiod::slotFinished( int /*_id*/ )
{
worked = TRUE;
app->exit_loop();
}
#endif