summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/filetransfer.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-console/filetransfer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/filetransfer.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/apps/opie-console/filetransfer.cpp b/noncore/apps/opie-console/filetransfer.cpp
index 221838c..5144941 100644
--- a/noncore/apps/opie-console/filetransfer.cpp
+++ b/noncore/apps/opie-console/filetransfer.cpp
@@ -96,97 +96,97 @@ void FileTransfer::sendFile( const QString& file ) {
96 if ( len == -1 ) 96 if ( len == -1 )
97 if ( (errno == ECHILD ) || (errno == EINTR ) ) 97 if ( (errno == ECHILD ) || (errno == EINTR ) )
98 continue; 98 continue;
99 99
100 // len == 0 or something like this 100 // len == 0 or something like this
101 break; 101 break;
102 } 102 }
103 if ( m_info[0] ) 103 if ( m_info[0] )
104 close( m_info[0] ); 104 close( m_info[0] );
105 105
106 106
107 107
108 /* replace by QSocketNotifier!!! */ 108 /* replace by QSocketNotifier!!! */
109 m_not = new QSocketNotifier(m_comm[0], QSocketNotifier::Read ); 109 m_not = new QSocketNotifier(m_comm[0], QSocketNotifier::Read );
110 connect(m_not, SIGNAL(activated(int) ), 110 connect(m_not, SIGNAL(activated(int) ),
111 this, SLOT(slotRead() ) ); 111 this, SLOT(slotRead() ) );
112 if ( pipe(m_term) < 0 ) 112 if ( pipe(m_term) < 0 )
113 m_term[0] = m_term[1] = 0; 113 m_term[0] = m_term[1] = 0;
114 114
115 ProcCtl::self()->add(m_pid, m_term[1] ); 115 ProcCtl::self()->add(m_pid, m_term[1] );
116 m_proc = new QSocketNotifier(m_term[0], QSocketNotifier::Read ); 116 m_proc = new QSocketNotifier(m_term[0], QSocketNotifier::Read );
117 connect(m_proc, SIGNAL(activated(int) ), 117 connect(m_proc, SIGNAL(activated(int) ),
118 this, SLOT(slotExec() ) ); 118 this, SLOT(slotExec() ) );
119 119
120 } 120 }
121 break; 121 break;
122 } 122 }
123} 123}
124/* 124/*
125 * let's call the one with the filename 125 * let's call the one with the filename
126 */ 126 */
127void FileTransfer::sendFile( const QFile& file ) { 127void FileTransfer::sendFile( const QFile& file ) {
128 sendFile( file.name() ); 128 sendFile( file.name() );
129} 129}
130 130
131/* 131/*
132 * setting up communication 132 * setting up communication
133 * between parent child and ioLayer 133 * between parent child and ioLayer
134 */ 134 */
135void FileTransfer::setupChild() { 135void FileTransfer::setupChild() {
136 /* 136 /*
137 * we do not want to read from our 137 * we do not want to read from our
138 * information channel 138 * information channel
139 */ 139 */
140 if (m_info[0] ) 140 if (m_info[0] )
141 close(m_info[0] ); 141 close(m_info[0] );
142 /* 142 /*
143 * FD_CLOEXEC will close the 143 * FD_CLOEXEC will close the
144 * fd on successfull exec 144 * fd on successful exec
145 */ 145 */
146 if (m_info[1] ) 146 if (m_info[1] )
147 fcntl(m_info[1], F_SETFD, FD_CLOEXEC ); 147 fcntl(m_info[1], F_SETFD, FD_CLOEXEC );
148 148
149 if (m_comm[0] ) 149 if (m_comm[0] )
150 close( m_comm[0] ); 150 close( m_comm[0] );
151 /* 151 /*
152 * now set the communication 152 * now set the communication
153 * m_fd STDIN_FILENO 153 * m_fd STDIN_FILENO
154 * STDOUT_FILENO 154 * STDOUT_FILENO
155 * STDERR_FILENO 155 * STDERR_FILENO
156 */ 156 */
157 dup2( m_fd, STDIN_FILENO ); 157 dup2( m_fd, STDIN_FILENO );
158 dup2( m_fd, STDOUT_FILENO ); 158 dup2( m_fd, STDOUT_FILENO );
159 dup2( m_comm[1], STDERR_FILENO ); 159 dup2( m_comm[1], STDERR_FILENO );
160} 160}
161 161
162/* 162/*
163 * read from the stderr of the child 163 * read from the stderr of the child
164 * process 164 * process
165 */ 165 */
166void FileTransfer::slotRead() { 166void FileTransfer::slotRead() {
167 QByteArray ar(4096); 167 QByteArray ar(4096);
168 int len = read(m_comm[0], ar.data(), 4096 ); 168 int len = read(m_comm[0], ar.data(), 4096 );
169 for (int i = 0; i < len; i++ ) { 169 for (int i = 0; i < len; i++ ) {
170 // printf("%c", ar[i] ); 170 // printf("%c", ar[i] );
171 } 171 }
172 ar.resize( len ); 172 ar.resize( len );
173 QString str( ar ); 173 QString str( ar );
174 QStringList lis = QStringList::split(' ', str ); 174 QStringList lis = QStringList::split(' ', str );
175 /* 175 /*
176 * Transfer finished.. either complete or incomplete 176 * Transfer finished.. either complete or incomplete
177 */ 177 */
178 if ( lis[0].simplifyWhiteSpace() == "Transfer" ) { 178 if ( lis[0].simplifyWhiteSpace() == "Transfer" ) {
179 return; 179 return;
180 } 180 }
181 /* 181 /*
182 * do progress reading 182 * do progress reading
183 */ 183 */
184 slotProgress( lis ); 184 slotProgress( lis );
185 185
186 186
187} 187}
188/* 188/*
189 * find the progress 189 * find the progress
190 */ 190 */
191void FileTransfer::slotProgress( const QStringList& list ) { 191void FileTransfer::slotProgress( const QStringList& list ) {
192 if ( m_type != SZ ) 192 if ( m_type != SZ )