author | llornkcor <llornkcor> | 2004-10-08 10:22:20 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2004-10-08 10:22:20 (UTC) |
commit | 0e41f335c0db28250216a5292a2b7bcee2a1cf4a (patch) (unidiff) | |
tree | cac0c40b6e35117b199b45bf5674215ceeb9abd9 | |
parent | b2e0fd018e1122f65dbbf8ab564e992988f35385 (diff) | |
download | opie-0e41f335c0db28250216a5292a2b7bcee2a1cf4a.zip opie-0e41f335c0db28250216a5292a2b7bcee2a1cf4a.tar.gz opie-0e41f335c0db28250216a5292a2b7bcee2a1cf4a.tar.bz2 |
this patch will add support for QD installing directly to opie device via sync. not functioning until QD 1.7.1 released. should compile for now
-rw-r--r-- | core/launcher/applauncher.h | 9 | ||||
-rw-r--r-- | core/launcher/documentlist.cpp | 31 | ||||
-rw-r--r-- | core/launcher/packageslave.cpp | 14 | ||||
-rw-r--r-- | core/launcher/packageslave.h | 2 | ||||
-rw-r--r-- | core/launcher/qrr.cpp | 220 | ||||
-rw-r--r-- | core/launcher/qrr.h | 66 | ||||
-rw-r--r-- | core/launcher/server.cpp | 391 | ||||
-rw-r--r-- | core/launcher/server.h | 12 | ||||
-rw-r--r-- | core/launcher/server.pro | 5 | ||||
-rw-r--r-- | core/launcher/serverapp.cpp | 7 |
10 files changed, 657 insertions, 100 deletions
diff --git a/core/launcher/applauncher.h b/core/launcher/applauncher.h index 4fd5491..22a458f 100644 --- a/core/launcher/applauncher.h +++ b/core/launcher/applauncher.h | |||
@@ -39,6 +39,7 @@ public: | |||
39 | ~AppLauncher(); | 39 | ~AppLauncher(); |
40 | 40 | ||
41 | bool isRunning(const QString &app); | 41 | bool isRunning(const QString &app); |
42 | const QMap<int,QString> &runningApplications() { return runningApps; } | ||
42 | 43 | ||
43 | static const int RAISE_TIMEOUT_MS; | 44 | static const int RAISE_TIMEOUT_MS; |
44 | 45 | ||
@@ -46,7 +47,7 @@ signals: | |||
46 | void launched(int pid, const QString &app); | 47 | void launched(int pid, const QString &app); |
47 | void terminated(int pid, const QString &app); | 48 | void terminated(int pid, const QString &app); |
48 | void connected(const QString &app); | 49 | void connected(const QString &app); |
49 | 50 | ||
50 | protected slots: | 51 | protected slots: |
51 | void sigStopped(int sigPid, int sigStatus); | 52 | void sigStopped(int sigPid, int sigStatus); |
52 | void received(const QCString& msg, const QByteArray& data); | 53 | void received(const QCString& msg, const QByteArray& data); |
@@ -65,12 +66,12 @@ private: | |||
65 | bool execute(const QString &c, const QString &document, bool noRaise = FALSE); | 66 | bool execute(const QString &c, const QString &document, bool noRaise = FALSE); |
66 | void kill( int pid ); | 67 | void kill( int pid ); |
67 | int pidForName( const QString & ); | 68 | int pidForName( const QString & ); |
68 | 69 | ||
69 | private: | 70 | private: |
70 | QMap<int,QString> runningApps; | 71 | QMap<int,QString> runningApps; |
71 | QMap<QString,int> waitingHeartbeat; | 72 | QMap<QString,int> waitingHeartbeat; |
72 | #ifdef Q_OS_WIN32 | 73 | #ifdef Q_OS_WIN32 |
73 | QList<QProcess> runningAppsProc; | 74 | QList<QProcess> runningAppsProc; |
74 | #endif | 75 | #endif |
75 | int qlPid; | 76 | int qlPid; |
76 | bool qlReady; | 77 | bool qlReady; |
diff --git a/core/launcher/documentlist.cpp b/core/launcher/documentlist.cpp index 44ceb0c..d8e7a83 100644 --- a/core/launcher/documentlist.cpp +++ b/core/launcher/documentlist.cpp | |||
@@ -387,10 +387,10 @@ void DocumentList::DiffAppLnks() | |||
387 | ++it1; | 387 | ++it1; |
388 | } | 388 | } |
389 | if (!found) { | 389 | if (!found) { |
390 | odebug << "Item " << j->name().ascii() << " needs to be added" << oendl; | 390 | odebug << "Item " << j->name().ascii() << " needs to be added" << oendl; |
391 | d->serverGui->applicationAdded( j->type(), *j ); | 391 | d->serverGui->applicationAdded( j->type(), *j ); |
392 | } | 392 | } |
393 | ++it2; | 393 | ++it2; |
394 | } | 394 | } |
395 | 395 | ||
396 | it1 = appLnkSet->children(); | 396 | it1 = appLnkSet->children(); |
@@ -403,13 +403,13 @@ void DocumentList::DiffAppLnks() | |||
403 | ++it2; | 403 | ++it2; |
404 | } | 404 | } |
405 | if (!found) { | 405 | if (!found) { |
406 | odebug << "Item " << i->name().ascii() << " needs to be removed" << oendl; | 406 | odebug << "Item " << i->name().ascii() << " needs to be removed" << oendl; |
407 | d->serverGui->applicationRemoved( i->type(), *i ); | 407 | d->serverGui->applicationRemoved( i->type(), *i ); |
408 | } | 408 | } |
409 | 409 | ||
410 | ++it1; | 410 | ++it1; |
411 | } | 411 | } |
412 | 412 | ||
413 | delete appLnkSet; | 413 | delete appLnkSet; |
414 | appLnkSet = appLnkSet2; | 414 | appLnkSet = appLnkSet2; |
415 | 415 | ||
@@ -422,10 +422,10 @@ void DocumentList::storageChanged() | |||
422 | t.start(); | 422 | t.start(); |
423 | DiffAppLnks(); | 423 | DiffAppLnks(); |
424 | // reloadAppLnks(); | 424 | // reloadAppLnks(); |
425 | odebug << "Reload App links took " << t.elapsed() << " ms" << oendl; | 425 | odebug << "Reload App links took " << t.elapsed() << " ms" << oendl; |
426 | reloadDocLnks(); | 426 | reloadDocLnks(); |
427 | // odebug << "Reload links took " << t.elapsed() << " ms " << oendl; | 427 | // odebug << "Reload links took " << t.elapsed() << " ms " << oendl; |
428 | odebug << "Reload All links took " << t.elapsed() << " ms" << oendl; | 428 | odebug << "Reload All links took " << t.elapsed() << " ms" << oendl; |
429 | // ### Optimization opportunity | 429 | // ### Optimization opportunity |
430 | // Could be a bit more intelligent and somehow work out which | 430 | // Could be a bit more intelligent and somehow work out which |
431 | // mtab entry has changed and then only scan that and add and remove | 431 | // mtab entry has changed and then only scan that and add and remove |
@@ -456,7 +456,18 @@ void DocumentList::sendAllDocLinks() | |||
456 | if ( f.open( IO_ReadOnly ) ) { | 456 | if ( f.open( IO_ReadOnly ) ) { |
457 | QTextStream ts( &f ); | 457 | QTextStream ts( &f ); |
458 | ts.setEncoding( QTextStream::UnicodeUTF8 ); | 458 | ts.setEncoding( QTextStream::UnicodeUTF8 ); |
459 | contents += ts.read(); | 459 | QString docLnk = ts.read(); |
460 | // Strip out the (stale) LinkFile entry | ||
461 | int start = docLnk.find( "\nLinkFile = " ) + 1; | ||
462 | if ( start > 0 ) { | ||
463 | int end = docLnk.find( "\n", start + 1 ) + 1; | ||
464 | contents += docLnk.left(start); | ||
465 | contents += docLnk.mid(end); | ||
466 | } else { | ||
467 | contents += docLnk; | ||
468 | } | ||
469 | contents += "LinkFile = " + doc->linkFile() + "\n"; | ||
470 | |||
460 | f.close(); | 471 | f.close(); |
461 | } else | 472 | } else |
462 | fake = TRUE; | 473 | fake = TRUE; |
diff --git a/core/launcher/packageslave.cpp b/core/launcher/packageslave.cpp index 0461432..abbc610 100644 --- a/core/launcher/packageslave.cpp +++ b/core/launcher/packageslave.cpp | |||
@@ -65,6 +65,10 @@ void PackageHandler::qcopMessage( const QCString &msg, const QByteArray &data ) | |||
65 | QString file; | 65 | QString file; |
66 | stream >> file; | 66 | stream >> file; |
67 | installPackage( file ); | 67 | installPackage( file ); |
68 | } else if ( msg == "installPackage(QString,QString)" ) { | ||
69 | QString file, dest; | ||
70 | stream >> file >> dest; | ||
71 | installPackage( file, dest ); | ||
68 | } else if ( msg == "removePackage(QString)" ) { | 72 | } else if ( msg == "removePackage(QString)" ) { |
69 | QString file; | 73 | QString file; |
70 | stream >> file; | 74 | stream >> file; |
@@ -93,7 +97,7 @@ void PackageHandler::qcopMessage( const QCString &msg, const QByteArray &data ) | |||
93 | } | 97 | } |
94 | } | 98 | } |
95 | 99 | ||
96 | void PackageHandler::installPackage( const QString &package ) | 100 | void PackageHandler::installPackage( const QString &package, const QString &dest ) |
97 | { | 101 | { |
98 | if ( mNoSpaceLeft ) { | 102 | if ( mNoSpaceLeft ) { |
99 | mNoSpaceLeft = FALSE; | 103 | mNoSpaceLeft = FALSE; |
@@ -102,7 +106,13 @@ void PackageHandler::installPackage( const QString &package ) | |||
102 | //return; | 106 | //return; |
103 | } | 107 | } |
104 | 108 | ||
105 | currentProcess = new QProcess( QStringList() << "ipkg" << "install" << package ); // No tr | 109 | QStringList cmd; |
110 | cmd << "ipkg"; | ||
111 | if ( !dest.isEmpty() ) { | ||
112 | cmd << "-d" << dest; | ||
113 | } | ||
114 | cmd << "install" << package; | ||
115 | currentProcess = new QProcess( cmd ); // No tr | ||
106 | connect( currentProcess, SIGNAL( processExited() ), SLOT( iProcessExited() ) ); | 116 | connect( currentProcess, SIGNAL( processExited() ), SLOT( iProcessExited() ) ); |
107 | connect( currentProcess, SIGNAL( readyReadStdout() ), SLOT( readyReadStdout() ) ); | 117 | connect( currentProcess, SIGNAL( readyReadStdout() ), SLOT( readyReadStdout() ) ); |
108 | connect( currentProcess, SIGNAL( readyReadStderr() ), SLOT( readyReadStderr() ) ); | 118 | connect( currentProcess, SIGNAL( readyReadStderr() ), SLOT( readyReadStderr() ) ); |
diff --git a/core/launcher/packageslave.h b/core/launcher/packageslave.h index 878b4c3..83dfe6f 100644 --- a/core/launcher/packageslave.h +++ b/core/launcher/packageslave.h | |||
@@ -38,7 +38,7 @@ public slots: | |||
38 | void redoPackages(); | 38 | void redoPackages(); |
39 | 39 | ||
40 | protected: | 40 | protected: |
41 | void installPackage( const QString &package ); | 41 | void installPackage( const QString &package, const QString &dest = QString::null ); |
42 | void removePackage( const QString &package ); | 42 | void removePackage( const QString &package ); |
43 | 43 | ||
44 | void addPackageFiles( const QString &location, const QString &listfile ); | 44 | void addPackageFiles( const QString &location, const QString &listfile ); |
diff --git a/core/launcher/qrr.cpp b/core/launcher/qrr.cpp new file mode 100644 index 0000000..5809ca9 --- a/dev/null +++ b/core/launcher/qrr.cpp | |||
@@ -0,0 +1,220 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of the Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #include "qrr.h" | ||
22 | |||
23 | #include <qtopia/qcopenvelope_qws.h> | ||
24 | #include <qfile.h> | ||
25 | #include <qtimer.h> | ||
26 | #include <qdialog.h> | ||
27 | #include <qlayout.h> | ||
28 | #include <qlabel.h> | ||
29 | #include <qprogressbar.h> | ||
30 | #include <qapplication.h> | ||
31 | #include <qevent.h> | ||
32 | |||
33 | |||
34 | class CenteringDialog : public QDialog | ||
35 | { | ||
36 | public: | ||
37 | CenteringDialog( QWidget *parent = 0, char *name = 0, bool modal = FALSE, WFlags f = 0 ); | ||
38 | virtual ~CenteringDialog(); | ||
39 | |||
40 | protected: | ||
41 | void resizeEvent( QResizeEvent *e ); | ||
42 | }; | ||
43 | |||
44 | CenteringDialog::CenteringDialog( QWidget *parent, char *name, bool modal, WFlags f ) | ||
45 | : QDialog( parent, name, modal, f ) | ||
46 | { | ||
47 | } | ||
48 | |||
49 | CenteringDialog::~CenteringDialog() | ||
50 | { | ||
51 | } | ||
52 | |||
53 | void CenteringDialog::resizeEvent( QResizeEvent *e ) | ||
54 | { | ||
55 | int dist = -((width() - e->oldSize().width()) / 2); | ||
56 | qDebug( "move %d", dist ); | ||
57 | move( pos().x() + dist, pos().y() ); | ||
58 | } | ||
59 | |||
60 | // ===================================================================== | ||
61 | |||
62 | QueuedRequestRunner::QueuedRequestRunner( QFile *f, QWidget *parent ) | ||
63 | : readyToDelete( FALSE ), waitingForMessages( FALSE ), file( 0 ) | ||
64 | { | ||
65 | file = f; | ||
66 | waitMsgs.setAutoDelete( TRUE ); | ||
67 | if ( parent ) { | ||
68 | progressDialog = new CenteringDialog( parent, 0, TRUE ); | ||
69 | QVBoxLayout *l = new QVBoxLayout( progressDialog ); | ||
70 | l->setMargin( 6 ); | ||
71 | l->setSpacing( 6 ); | ||
72 | progressLabel = new QLabel( progressDialog ); | ||
73 | progressLabel->setText( tr("Processing Queued Requests") ); | ||
74 | progressBar = new QProgressBar( progressDialog ); | ||
75 | l->addWidget( progressLabel ); | ||
76 | l->addWidget( progressBar ); | ||
77 | //progressDialog->setFixedSize( qApp->desktop()->width(), qApp->desktop()->height() ); | ||
78 | progressDialog->show(); | ||
79 | } | ||
80 | int totalSteps = countSteps(); | ||
81 | if ( parent ) { | ||
82 | qDebug( "%d steps", totalSteps ); | ||
83 | progressBar->setTotalSteps( totalSteps ); | ||
84 | progressBar->setProgress( 0 ); | ||
85 | } | ||
86 | file->open( IO_ReadOnly ); | ||
87 | } | ||
88 | |||
89 | QueuedRequestRunner::~QueuedRequestRunner() | ||
90 | { | ||
91 | delete progressDialog; | ||
92 | delete file; | ||
93 | } | ||
94 | |||
95 | void QueuedRequestRunner::process() | ||
96 | { | ||
97 | if ( process( FALSE ) ) { | ||
98 | if ( !waitingForMessages || action == "wait" ) | ||
99 | QTimer::singleShot( 100, this, SLOT(process()) ); | ||
100 | } else { | ||
101 | file->remove(); | ||
102 | emit finished(); | ||
103 | } | ||
104 | |||
105 | } | ||
106 | |||
107 | int QueuedRequestRunner::countSteps() | ||
108 | { | ||
109 | int totalSteps = 0; | ||
110 | bool more = TRUE; | ||
111 | file->open( IO_ReadOnly ); | ||
112 | while ( more ) { | ||
113 | steps = 0; | ||
114 | more = process( TRUE ); | ||
115 | totalSteps += steps; | ||
116 | } | ||
117 | file->close(); | ||
118 | waitingForMessages = FALSE; | ||
119 | return totalSteps; | ||
120 | } | ||
121 | |||
122 | bool QueuedRequestRunner::process( bool counting ) | ||
123 | { | ||
124 | QDataStream stream( file ); | ||
125 | stream >> action; | ||
126 | if ( action == "info" ) { | ||
127 | QString message; | ||
128 | stream >> message; | ||
129 | qDebug( "info %s", message.latin1() ); | ||
130 | if ( counting ) { | ||
131 | steps++; | ||
132 | } else { | ||
133 | progressLabel->setText( message ); | ||
134 | } | ||
135 | } else if ( action == "qcop" ) { | ||
136 | QCString channel; | ||
137 | QCString message; | ||
138 | int args; | ||
139 | stream >> channel >> message >> args; | ||
140 | qDebug( "qcop %s %s", channel.data(), message.data() ); | ||
141 | #ifndef QT_NO_COP | ||
142 | QCopEnvelope *e = 0; | ||
143 | if ( !counting ) { | ||
144 | e = new QCopEnvelope( channel, message ); | ||
145 | } | ||
146 | #endif | ||
147 | QCString type; | ||
148 | for ( int i = 0; i < args; ++i ) { | ||
149 | stream >> type; | ||
150 | if ( type == "QString" ) { | ||
151 | QString arg; | ||
152 | stream >> arg; | ||
153 | qDebug( " %s %s", type.data(), arg.latin1() ); | ||
154 | #ifndef QT_NO_COP | ||
155 | if ( !counting ) | ||
156 | (*e) << arg; | ||
157 | #endif | ||
158 | } else if ( type == "int" ) { | ||
159 | int arg; | ||
160 | stream >> arg; | ||
161 | qDebug( " %s %d", type.data(), arg ); | ||
162 | #ifndef QT_NO_COP | ||
163 | if ( !counting ) | ||
164 | (*e) << arg; | ||
165 | #endif | ||
166 | } else { | ||
167 | qDebug( "\tBUG unknown type '%s'!", type.data() ); | ||
168 | } | ||
169 | } | ||
170 | if ( counting ) { | ||
171 | steps++; | ||
172 | } else { | ||
173 | #ifndef QT_NO_COP | ||
174 | // this causes the QCop message to be sent | ||
175 | delete e; | ||
176 | #endif | ||
177 | } | ||
178 | } else if ( action == "wait" ) { | ||
179 | int messageCount; | ||
180 | QCString message; | ||
181 | waitMsgs.clear(); | ||
182 | stream >> messageCount; | ||
183 | for ( int i = 0; i < messageCount; ++i ) { | ||
184 | stream >> message; | ||
185 | qDebug( "wait %s", message.data() ); | ||
186 | if ( !counting ) { | ||
187 | waitMsgs.append( new QCString( message ) ); | ||
188 | } | ||
189 | } | ||
190 | if ( counting ) | ||
191 | steps++; | ||
192 | waitingForMessages = TRUE; | ||
193 | } else { | ||
194 | qDebug( "\tBUG unknown action '%s'!", action.data() ); | ||
195 | } | ||
196 | |||
197 | if ( !counting ) { | ||
198 | progressBar->setProgress( progressBar->progress() + 1 ); | ||
199 | } | ||
200 | |||
201 | return !file->atEnd(); | ||
202 | } | ||
203 | |||
204 | void QueuedRequestRunner::desktopMessage( const QCString &message, const QByteArray & ) | ||
205 | { | ||
206 | bool found = FALSE; | ||
207 | QCString *msg; | ||
208 | for ( QListIterator<QCString> iter( waitMsgs ); ( msg = iter.current() ) != 0; ++iter ) { | ||
209 | if ( *msg == message ) { | ||
210 | found = TRUE; | ||
211 | break; | ||
212 | } | ||
213 | } | ||
214 | if ( found ) { | ||
215 | waitMsgs.clear(); | ||
216 | waitingForMessages = FALSE; | ||
217 | QTimer::singleShot( 100, this, SLOT(process()) ); | ||
218 | } | ||
219 | } | ||
220 | |||
diff --git a/core/launcher/qrr.h b/core/launcher/qrr.h new file mode 100644 index 0000000..4c0a8db --- a/dev/null +++ b/core/launcher/qrr.h | |||
@@ -0,0 +1,66 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of the Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | #ifndef QRR_H | ||
21 | #define QRR_H | ||
22 | |||
23 | #include <qobject.h> | ||
24 | #include <qlist.h> | ||
25 | #include <qcstring.h> | ||
26 | |||
27 | class QFile; | ||
28 | class QDialog; | ||
29 | class QLabel; | ||
30 | class QProgressBar; | ||
31 | class QWidget; | ||
32 | |||
33 | class QueuedRequestRunner : public QObject | ||
34 | { | ||
35 | Q_OBJECT | ||
36 | public: | ||
37 | QueuedRequestRunner( QFile *f, QWidget *parent ); | ||
38 | virtual ~QueuedRequestRunner(); | ||
39 | |||
40 | void desktopMessage( const QCString &message, const QByteArray &data ); | ||
41 | |||
42 | bool readyToDelete; | ||
43 | bool waitingForMessages; | ||
44 | |||
45 | signals: | ||
46 | void finished(); | ||
47 | |||
48 | public slots: | ||
49 | void process(); | ||
50 | |||
51 | private: | ||
52 | int countSteps(); | ||
53 | bool process( bool counting ); | ||
54 | |||
55 | QFile *file; | ||
56 | QList<QCString> waitMsgs; | ||
57 | QDialog *progressDialog; | ||
58 | QLabel *progressLabel; | ||
59 | QProgressBar *progressBar; | ||
60 | int steps; | ||
61 | QCString action; | ||
62 | }; | ||
63 | |||
64 | |||
65 | #endif // QRR_H | ||
66 | |||
diff --git a/core/launcher/server.cpp b/core/launcher/server.cpp index 3bef36e..524e6dd 100644 --- a/core/launcher/server.cpp +++ b/core/launcher/server.cpp | |||
@@ -35,6 +35,7 @@ | |||
35 | #include "suspendmonitor.h" | 35 | #include "suspendmonitor.h" |
36 | #endif | 36 | #endif |
37 | #include "documentlist.h" | 37 | #include "documentlist.h" |
38 | #include "qrr.h" | ||
38 | 39 | ||
39 | /* OPIE */ | 40 | /* OPIE */ |
40 | #include <opie2/odebug.h> | 41 | #include <opie2/odebug.h> |
@@ -117,6 +118,10 @@ static Global::Command builtins[] = { | |||
117 | { 0, calibrate, 0, 0 }, | 118 | { 0, calibrate, 0, 0 }, |
118 | }; | 119 | }; |
119 | 120 | ||
121 | #ifdef QPE_HAVE_DIRECT_ACCESS | ||
122 | extern void readyDirectAccess(QString cardInfo, QString installLocations); | ||
123 | extern const char *directAccessQueueFile(); | ||
124 | #endif | ||
120 | 125 | ||
121 | //--------------------------------------------------------------------------- | 126 | //--------------------------------------------------------------------------- |
122 | 127 | ||
@@ -137,6 +142,7 @@ Server::Server() : | |||
137 | /* tid_today = startTimer(3600*2*1000);*/ | 142 | /* tid_today = startTimer(3600*2*1000);*/ |
138 | last_today_show = QDate::currentDate(); | 143 | last_today_show = QDate::currentDate(); |
139 | 144 | ||
145 | #warning FIXME support TempScreenSaverMode | ||
140 | #if 0 | 146 | #if 0 |
141 | tsmMonitor = new TempScreenSaverMode(); | 147 | tsmMonitor = new TempScreenSaverMode(); |
142 | connect( tsmMonitor, SIGNAL(forceSuspend()), qApp, SIGNAL(power()) ); | 148 | connect( tsmMonitor, SIGNAL(forceSuspend()), qApp, SIGNAL(power()) ); |
@@ -154,6 +160,13 @@ Server::Server() : | |||
154 | storage = new StorageInfo( this ); | 160 | storage = new StorageInfo( this ); |
155 | connect( storage, SIGNAL(disksChanged()), this, SLOT(storageChanged()) ); | 161 | connect( storage, SIGNAL(disksChanged()), this, SLOT(storageChanged()) ); |
156 | 162 | ||
163 | |||
164 | #ifdef QPE_HAVE_DIRECT_ACCESS | ||
165 | QCopChannel *desktopChannel = new QCopChannel( "QPE/Desktop", this ); | ||
166 | connect( desktopChannel, SIGNAL(received( const QCString &, const QByteArray & )), | ||
167 | this, SLOT(desktopMessage( const QCString &, const QByteArray & )) ); | ||
168 | #endif | ||
169 | |||
157 | // start services | 170 | // start services |
158 | startTransferServer(); | 171 | startTransferServer(); |
159 | (void) new IrServer( this ); | 172 | (void) new IrServer( this ); |
@@ -197,6 +210,31 @@ Server::~Server() | |||
197 | } | 210 | } |
198 | 211 | ||
199 | 212 | ||
213 | static bool hasVisibleWindow(const QString& clientname, bool partial) | ||
214 | { | ||
215 | #ifdef QWS | ||
216 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | ||
217 | QWSWindow* w; | ||
218 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | ||
219 | if ( w->client()->identity() == clientname ) { | ||
220 | if ( partial && !w->isFullyObscured() ) | ||
221 | return TRUE; | ||
222 | if ( !partial && !w->isFullyObscured() && !w->isPartiallyObscured() ) { | ||
223 | # if QT_VERSION < 0x030000 | ||
224 | QRect mwr = qt_screen->mapToDevice(qt_maxWindowRect, | ||
225 | QSize(qt_screen->width(),qt_screen->height()) ); | ||
226 | # else | ||
227 | QRect mwr = qt_maxWindowRect; | ||
228 | # endif | ||
229 | if ( mwr.contains(w->requested().boundingRect()) ) | ||
230 | return TRUE; | ||
231 | } | ||
232 | } | ||
233 | } | ||
234 | #endif | ||
235 | return FALSE; | ||
236 | } | ||
237 | |||
200 | void Server::activate(const ODeviceButton* button, bool held) | 238 | void Server::activate(const ODeviceButton* button, bool held) |
201 | { | 239 | { |
202 | Global::terminateBuiltin("calibrate"); // No tr | 240 | Global::terminateBuiltin("calibrate"); // No tr |
@@ -292,48 +330,34 @@ void Server::systemMsg(const QCString &msg, const QByteArray &data) | |||
292 | 330 | ||
293 | if ( qcopBridge ) | 331 | if ( qcopBridge ) |
294 | qcopBridge->authorizeConnections(); | 332 | qcopBridge->authorizeConnections(); |
295 | } else | 333 | #warning FIXME support TempScreenSaverMode |
296 | |||
297 | #if 0 | 334 | #if 0 |
298 | /* ### FIXME support TempScreenSaverMode */ | 335 | } else if ( msg == "setTempScreenSaverMode(int,int)" ) { |
299 | if ( msg == "setTempScreenSaverMode(int,int)" ) { | ||
300 | int mode, pid; | 336 | int mode, pid; |
301 | stream >> mode >> pid; | 337 | stream >> mode >> pid; |
302 | tsmMonitor->setTempMode(mode, pid); | 338 | tsmMonitor->setTempMode(mode, pid); |
303 | } else | ||
304 | #endif | 339 | #endif |
305 | 340 | } else if ( msg == "linkChanged(QString)" ) { | |
306 | if ( msg == "linkChanged(QString)" ) { | ||
307 | QString link; | 341 | QString link; |
308 | stream >> link; | 342 | stream >> link; |
309 | odebug << "desktop.cpp systemMsg -> linkchanged( " << link << " )" << oendl; | 343 | odebug << "desktop.cpp systemMsg -> linkchanged( " << link << " )" << oendl; |
310 | docList->linkChanged(link); | 344 | docList->linkChanged(link); |
311 | } else | 345 | } else if ( msg == "serviceChanged(QString)" ) { |
312 | |||
313 | if ( msg == "serviceChanged(QString)" ) { | ||
314 | MimeType::updateApplications(); | 346 | MimeType::updateApplications(); |
315 | } else | 347 | } else if ( msg == "mkdir(QString)" ) { |
316 | |||
317 | if ( msg == "mkdir(QString)" ) { | ||
318 | QString dir; | 348 | QString dir; |
319 | stream >> dir; | 349 | stream >> dir; |
320 | if ( !dir.isEmpty() ) | 350 | if ( !dir.isEmpty() ) |
321 | mkdir( dir ); | 351 | mkdir( dir ); |
322 | } else | 352 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { |
323 | |||
324 | if ( msg == "rdiffGenSig(QString,QString)" ) { | ||
325 | QString baseFile, sigFile; | 353 | QString baseFile, sigFile; |
326 | stream >> baseFile >> sigFile; | 354 | stream >> baseFile >> sigFile; |
327 | QRsync::generateSignature( baseFile, sigFile ); | 355 | QRsync::generateSignature( baseFile, sigFile ); |
328 | } else | 356 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { |
329 | |||
330 | if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { | ||
331 | QString baseFile, sigFile, deltaFile; | 357 | QString baseFile, sigFile, deltaFile; |
332 | stream >> baseFile >> sigFile >> deltaFile; | 358 | stream >> baseFile >> sigFile >> deltaFile; |
333 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); | 359 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); |
334 | } else | 360 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { |
335 | |||
336 | if ( msg == "rdiffApplyPatch(QString,QString)" ) { | ||
337 | QString baseFile, deltaFile; | 361 | QString baseFile, deltaFile; |
338 | stream >> baseFile >> deltaFile; | 362 | stream >> baseFile >> deltaFile; |
339 | if ( !QFile::exists( baseFile ) ) { | 363 | if ( !QFile::exists( baseFile ) ) { |
@@ -346,18 +370,14 @@ void Server::systemMsg(const QCString &msg, const QByteArray &data) | |||
346 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); | 370 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); |
347 | e << baseFile; | 371 | e << baseFile; |
348 | #endif | 372 | #endif |
349 | } else | 373 | } else if ( msg == "rdiffCleanup()" ) { |
350 | |||
351 | if ( msg == "rdiffCleanup()" ) { | ||
352 | mkdir( "/tmp/rdiff" ); | 374 | mkdir( "/tmp/rdiff" ); |
353 | QDir dir; | 375 | QDir dir; |
354 | dir.setPath( "/tmp/rdiff" ); | 376 | dir.setPath( "/tmp/rdiff" ); |
355 | QStringList entries = dir.entryList(); | 377 | QStringList entries = dir.entryList(); |
356 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) | 378 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) |
357 | dir.remove( *it ); | 379 | dir.remove( *it ); |
358 | } else | 380 | } else if ( msg == "sendHandshakeInfo()" ) { |
359 | |||
360 | if ( msg == "sendHandshakeInfo()" ) { | ||
361 | QString home = getenv( "HOME" ); | 381 | QString home = getenv( "HOME" ); |
362 | #ifndef QT_NO_COP | 382 | #ifndef QT_NO_COP |
363 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); | 383 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); |
@@ -365,21 +385,17 @@ void Server::systemMsg(const QCString &msg, const QByteArray &data) | |||
365 | int locked = (int) ServerApplication::screenLocked(); | 385 | int locked = (int) ServerApplication::screenLocked(); |
366 | e << locked; | 386 | e << locked; |
367 | #endif | 387 | #endif |
368 | } else | 388 | } else if ( msg == "sendVersionInfo()" ) { |
369 | |||
370 | /* | 389 | /* |
371 | * QtopiaDesktop relies on the major number | 390 | * QtopiaDesktop relies on the major number |
372 | * to start with 1. We're at 0.9 | 391 | * to start with 1. |
373 | * so wee need to fake at least 1.4 to be able | 392 | * we need to fake at least 1.4 to be able |
374 | * to sync with QtopiaDesktop1.6 | 393 | * to sync with QtopiaDesktop1.6 |
375 | */ | 394 | */ |
376 | if ( msg == "sendVersionInfo()" ) { | ||
377 | QCopEnvelope e( "QPE/Desktop", "versionInfo(QString,QString)" ); | 395 | QCopEnvelope e( "QPE/Desktop", "versionInfo(QString,QString)" ); |
378 | /* ### FIXME Architecture ### */ | 396 | /* ### FIXME Architecture ### */ |
379 | e << QString::fromLatin1("1.7") << "Uncustomized Device"; | 397 | e << QString::fromLatin1("1.7") << "Uncustomized Device"; |
380 | } else | 398 | } else if ( msg == "sendCardInfo()" ) { |
381 | |||
382 | if ( msg == "sendCardInfo()" ) { | ||
383 | #ifndef QT_NO_COP | 399 | #ifndef QT_NO_COP |
384 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); | 400 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); |
385 | #endif | 401 | #endif |
@@ -409,9 +425,12 @@ void Server::systemMsg(const QCString &msg, const QByteArray &data) | |||
409 | #ifndef QT_NO_COP | 425 | #ifndef QT_NO_COP |
410 | e << s; | 426 | e << s; |
411 | #endif | 427 | #endif |
412 | } else | 428 | } else if ( msg == "sendInstallLocations()" ) { |
413 | 429 | #ifndef QT_NO_COP | |
414 | if ( msg == "sendSyncDate(QString)" ) { | 430 | QCopEnvelope e( "QPE/Desktop", "installLocations(QString)" ); |
431 | e << installLocationsString(); | ||
432 | #endif | ||
433 | } else if ( msg == "sendSyncDate(QString)" ) { | ||
415 | QString app; | 434 | QString app; |
416 | stream >> app; | 435 | stream >> app; |
417 | Config cfg( "qpe" ); | 436 | Config cfg( "qpe" ); |
@@ -422,55 +441,48 @@ void Server::systemMsg(const QCString &msg, const QByteArray &data) | |||
422 | #endif | 441 | #endif |
423 | //odebug << "QPE/System sendSyncDate for " << app.latin1() << ": response " | 442 | //odebug << "QPE/System sendSyncDate for " << app.latin1() << ": response " |
424 | // << cfg.readEntry( app ).latin1() << oendl; | 443 | // << cfg.readEntry( app ).latin1() << oendl; |
425 | } else | 444 | } else if ( msg == "setSyncDate(QString,QString)" ) { |
426 | |||
427 | if ( msg == "setSyncDate(QString,QString)" ) { | ||
428 | QString app, date; | 445 | QString app, date; |
429 | stream >> app >> date; | 446 | stream >> app >> date; |
430 | Config cfg( "qpe" ); | 447 | Config cfg( "qpe" ); |
431 | cfg.setGroup("SyncDate"); | 448 | cfg.setGroup("SyncDate"); |
432 | cfg.writeEntry( app, date ); | 449 | cfg.writeEntry( app, date ); |
433 | //odebug << "setSyncDate(QString,QString) " << app << " " << date << "" << oendl; | 450 | //odebug << "setSyncDate(QString,QString) " << app << " " << date << "" << oendl; |
434 | } else | 451 | } else if ( msg == "startSync(QString)" ) { |
435 | |||
436 | if ( msg == "startSync(QString)" ) { | ||
437 | QString what; | 452 | QString what; |
438 | stream >> what; | 453 | stream >> what; |
439 | delete syncDialog; | 454 | delete syncDialog; |
440 | syncDialog = new SyncDialog( this, what ); | 455 | syncDialog = new SyncDialog( this, what ); |
441 | syncDialog->show(); | 456 | syncDialog->show(); |
442 | connect( syncDialog, SIGNAL(cancel()), SLOT(cancelSync()) ); | 457 | connect( syncDialog, SIGNAL(cancel()), SLOT(cancelSync()) ); |
443 | } else | 458 | } else if ( msg == "stopSync()") { |
444 | |||
445 | if ( msg == "stopSync()") { | ||
446 | delete syncDialog; | 459 | delete syncDialog; |
447 | syncDialog = 0; | 460 | syncDialog = 0; |
448 | } else | 461 | } else if (msg == "restoreDone(QString)") { |
449 | |||
450 | if (msg == "restoreDone(QString)") { | ||
451 | docList->restoreDone(); | 462 | docList->restoreDone(); |
452 | } else | 463 | } else if ( msg == "getAllDocLinks()" ) { |
453 | |||
454 | if ( msg == "getAllDocLinks()" ) { | ||
455 | docList->sendAllDocLinks(); | 464 | docList->sendAllDocLinks(); |
456 | } else | 465 | } |
457 | 466 | #ifdef QPE_HAVE_DIRECT_ACCESS | |
467 | else if ( msg == "prepareDirectAccess()" ) { | ||
468 | prepareDirectAccess(); | ||
469 | } else if ( msg == "postDirectAccess()" ) { | ||
470 | postDirectAccess(); | ||
471 | } | ||
472 | #endif | ||
458 | #ifdef Q_WS_QWS | 473 | #ifdef Q_WS_QWS |
459 | if ( msg == "setMouseProto(QString)" ) { | 474 | |
475 | else if ( msg == "setMouseProto(QString)" ) { | ||
460 | QString mice; | 476 | QString mice; |
461 | stream >> mice; | 477 | stream >> mice; |
462 | setenv("QWS_MOUSE_PROTO",mice.latin1(),1); | 478 | setenv("QWS_MOUSE_PROTO",mice.latin1(),1); |
463 | qwsServer->openMouse(); | 479 | qwsServer->openMouse(); |
464 | } else | 480 | } else if ( msg == "setKeyboard(QString)" ) { |
465 | |||
466 | if ( msg == "setKeyboard(QString)" ) { | ||
467 | QString kb; | 481 | QString kb; |
468 | stream >> kb; | 482 | stream >> kb; |
469 | setenv("QWS_KEYBOARD",kb.latin1(),1); | 483 | setenv("QWS_KEYBOARD",kb.latin1(),1); |
470 | qwsServer->openKeyboard(); | 484 | qwsServer->openKeyboard(); |
471 | } else | 485 | } else if ( msg == "setKeyboardAutoRepeat(int,int)" ) { |
472 | |||
473 | if ( msg == "setKeyboardAutoRepeat(int,int)" ) { | ||
474 | int delay, period; | 486 | int delay, period; |
475 | stream >> delay >> period; | 487 | stream >> delay >> period; |
476 | qwsSetKeyboardAutoRepeat( delay, period ); | 488 | qwsSetKeyboardAutoRepeat( delay, period ); |
@@ -478,18 +490,14 @@ void Server::systemMsg(const QCString &msg, const QByteArray &data) | |||
478 | cfg.setGroup("Keyboard"); | 490 | cfg.setGroup("Keyboard"); |
479 | cfg.writeEntry( "RepeatDelay", delay ); | 491 | cfg.writeEntry( "RepeatDelay", delay ); |
480 | cfg.writeEntry( "RepeatPeriod", period ); | 492 | cfg.writeEntry( "RepeatPeriod", period ); |
481 | } else | 493 | } else if ( msg == "setKeyboardLayout(QString)" ) { |
482 | |||
483 | if ( msg == "setKeyboardLayout(QString)" ) { | ||
484 | QString kb; | 494 | QString kb; |
485 | stream >> kb; | 495 | stream >> kb; |
486 | setKeyboardLayout( kb ); | 496 | setKeyboardLayout( kb ); |
487 | Config cfg( "qpe" ); | 497 | Config cfg( "qpe" ); |
488 | cfg.setGroup("Keyboard"); | 498 | cfg.setGroup("Keyboard"); |
489 | cfg.writeEntry( "Layout", kb ); | 499 | cfg.writeEntry( "Layout", kb ); |
490 | } else | 500 | } else if ( msg == "autoStart(QString)" ) { |
491 | |||
492 | if ( msg == "autoStart(QString)" ) { | ||
493 | QString appName; | 501 | QString appName; |
494 | stream >> appName; | 502 | stream >> appName; |
495 | Config cfg( "autostart" ); | 503 | Config cfg( "autostart" ); |
@@ -497,9 +505,7 @@ void Server::systemMsg(const QCString &msg, const QByteArray &data) | |||
497 | if ( appName.compare("clear") == 0){ | 505 | if ( appName.compare("clear") == 0){ |
498 | cfg.writeEntry("Apps", ""); | 506 | cfg.writeEntry("Apps", ""); |
499 | } | 507 | } |
500 | } else | 508 | } else if ( msg == "autoStart(QString,QString)" ) { |
501 | |||
502 | if ( msg == "autoStart(QString,QString)" ) { | ||
503 | QString modifier, appName; | 509 | QString modifier, appName; |
504 | stream >> modifier >> appName; | 510 | stream >> modifier >> appName; |
505 | Config cfg( "autostart" ); | 511 | Config cfg( "autostart" ); |
@@ -520,9 +526,7 @@ void Server::systemMsg(const QCString &msg, const QByteArray &data) | |||
520 | } | 526 | } |
521 | } | 527 | } |
522 | // case the autostart feature should be delayed | 528 | // case the autostart feature should be delayed |
523 | } else | 529 | } else if ( msg == "autoStart(QString,QString,QString)") { |
524 | |||
525 | if ( msg == "autoStart(QString,QString,QString)") { | ||
526 | QString modifier, appName, delay; | 530 | QString modifier, appName, delay; |
527 | stream >> modifier >> appName >> delay; | 531 | stream >> modifier >> appName >> delay; |
528 | Config cfg( "autostart" ); | 532 | Config cfg( "autostart" ); |
@@ -539,19 +543,71 @@ void Server::systemMsg(const QCString &msg, const QByteArray &data) | |||
539 | #endif | 543 | #endif |
540 | } | 544 | } |
541 | 545 | ||
546 | QString Server::cardInfoString() | ||
547 | { | ||
548 | storage->update(); | ||
549 | const QList<FileSystem> &fs = storage->fileSystems(); | ||
550 | QListIterator<FileSystem> it ( fs ); | ||
551 | QString s; | ||
552 | QString homeDir = getenv("HOME"); | ||
553 | QString homeFs, homeFsPath; | ||
554 | for ( ; it.current(); ++it ) { | ||
555 | int k4 = (*it)->blockSize()/256; | ||
556 | if ( (*it)->isRemovable() ) { | ||
557 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr | ||
558 | + QString::number( (*it)->availBlocks() * k4/4 ) | ||
559 | + "K " + (*it)->options() + ";"; | ||
560 | } else if ( homeDir.contains( (*it)->path() ) && | ||
561 | (*it)->path().length() > homeFsPath.length() ) { | ||
562 | homeFsPath = (*it)->path(); | ||
563 | homeFs = | ||
564 | (*it)->name() + "=" + homeDir + "/Documents " // No tr | ||
565 | + QString::number( (*it)->availBlocks() * k4/4 ) | ||
566 | + "K " + (*it)->options() + ";"; | ||
567 | } | ||
568 | } | ||
569 | if ( !homeFs.isEmpty() ) | ||
570 | s += homeFs; | ||
571 | return s; | ||
572 | } | ||
573 | |||
574 | QString Server::installLocationsString() | ||
575 | { | ||
576 | storage->update(); | ||
577 | const QList<FileSystem> &fs = storage->fileSystems(); | ||
578 | QListIterator<FileSystem> it ( fs ); | ||
579 | QString s; | ||
580 | QString homeDir = getenv("HOME"); | ||
581 | QString homeFs, homeFsPath; | ||
582 | for ( ; it.current(); ++it ) { | ||
583 | int k4 = (*it)->blockSize()/256; | ||
584 | if ( (*it)->isRemovable() ) { | ||
585 | s += (*it)->name() + "=" + (*it)->path() + " " // No tr | ||
586 | + QString::number( (*it)->availBlocks() * k4/4 ) | ||
587 | + "K " + (*it)->options() + ";"; | ||
588 | } else if ( homeDir.contains( (*it)->path() ) && | ||
589 | (*it)->path().length() > homeFsPath.length() ) { | ||
590 | homeFsPath = (*it)->path(); | ||
591 | homeFs = | ||
592 | (*it)->name() + "=" + homeDir + " " // No tr | ||
593 | + QString::number( (*it)->availBlocks() * k4/4 ) | ||
594 | + "K " + (*it)->options() + ";"; | ||
595 | } | ||
596 | } | ||
597 | if ( !homeFs.isEmpty() ) | ||
598 | s = homeFs + s; | ||
599 | return s; | ||
600 | } | ||
601 | |||
542 | void Server::receiveTaskBar(const QCString &msg, const QByteArray &data) | 602 | void Server::receiveTaskBar(const QCString &msg, const QByteArray &data) |
543 | { | 603 | { |
544 | QDataStream stream( data, IO_ReadOnly ); | 604 | QDataStream stream( data, IO_ReadOnly ); |
545 | 605 | ||
546 | if ( msg == "reloadApps()" ) { | 606 | if ( msg == "reloadApps()" ) { |
547 | docList->reloadAppLnks(); | 607 | docList->reloadAppLnks(); |
548 | } else | 608 | } else if ( msg == "soundAlarm()" ) { |
549 | |||
550 | if ( msg == "soundAlarm()" ) { | ||
551 | ServerApplication::soundAlarm(); | 609 | ServerApplication::soundAlarm(); |
552 | } else | 610 | } else if ( msg == "setLed(int,bool)" ) { |
553 | |||
554 | if ( msg == "setLed(int,bool)" ) { | ||
555 | int led, status; | 611 | int led, status; |
556 | stream >> led >> status; | 612 | stream >> led >> status; |
557 | 613 | ||
@@ -748,3 +804,176 @@ void Server::preloadApps() | |||
748 | #endif | 804 | #endif |
749 | } | 805 | } |
750 | } | 806 | } |
807 | |||
808 | // This is only called if QPE_HAVE_DIRECT_ACCESS is defined | ||
809 | void Server::prepareDirectAccess() | ||
810 | { | ||
811 | qDebug( "Server::prepareDirectAccess()" ); | ||
812 | // Put up a pretty dialog | ||
813 | syncDialog = new SyncDialog( this, tr("USB Lock") ); | ||
814 | syncDialog->show(); | ||
815 | |||
816 | // Prevent the PDA from acting as a PDA | ||
817 | terminateServers(); | ||
818 | |||
819 | // suspend the mtab monitor | ||
820 | #ifndef QT_NO_COP | ||
821 | { | ||
822 | QCopEnvelope e( "QPE/Stabmon", "suspendMonitor()" ); | ||
823 | } | ||
824 | #endif | ||
825 | |||
826 | // send out a flush message | ||
827 | // once flushes are done call runDirectAccess() | ||
828 | // We just count the number of apps and set a timer. | ||
829 | // Either the timer expires or the correct number of apps responds. | ||
830 | // Note: quicklauncher isn't in the runningApps list but it responds | ||
831 | // to the flush so we start the counter at 1 | ||
832 | pendingFlushes = 1; | ||
833 | directAccessRun = FALSE; | ||
834 | for ( QMap<int,QString>::ConstIterator it = | ||
835 | appLauncher->runningApplications().begin(); | ||
836 | it != appLauncher->runningApplications().end(); | ||
837 | ++it ) { | ||
838 | pendingFlushes++; | ||
839 | } | ||
840 | #ifndef QT_NO_COP | ||
841 | QCopEnvelope e1( "QPE/System", "flush()" ); | ||
842 | #endif | ||
843 | QTimer::singleShot( 10000, this, SLOT(runDirectAccess()) ); | ||
844 | #warning FIXME support TempScreenSaverMode | ||
845 | #if 0 | ||
846 | QPEApplication::setTempScreenSaverMode(QPEApplication::DisableSuspend); | ||
847 | #endif | ||
848 | } | ||
849 | |||
850 | // This is only connected if QPE_HAVE_DIRECT_ACCESS is defined | ||
851 | // It fakes the presence of Qtopia Desktop | ||
852 | void Server::desktopMessage( const QCString &message, const QByteArray &data ) | ||
853 | { | ||
854 | QDataStream stream( data, IO_ReadOnly ); | ||
855 | if ( message == "flushDone(QString)" ) { | ||
856 | QString app; | ||
857 | stream >> app; | ||
858 | qDebug( "flushDone from %s", app.latin1() ); | ||
859 | if ( --pendingFlushes == 0 ) { | ||
860 | qDebug( "pendingFlushes == 0, all the apps responded" ); | ||
861 | runDirectAccess(); | ||
862 | } | ||
863 | } else if ( message == "installStarted(QString)" ) { | ||
864 | QString package; | ||
865 | stream >> package; | ||
866 | qDebug( "\tInstall Started for package %s", package.latin1() ); | ||
867 | } else if ( message == "installStep(QString)" ) { | ||
868 | QString step; | ||
869 | stream >> step; | ||
870 | qDebug( "\tInstall Step %s", step.latin1() ); | ||
871 | } else if ( message == "installDone(QString)" ) { | ||
872 | QString package; | ||
873 | stream >> package; | ||
874 | qDebug( "\tInstall Finished for package %s", package.latin1() ); | ||
875 | } else if ( message == "installFailed(QString,int,QString)" ) { | ||
876 | QString package, error; | ||
877 | int status; | ||
878 | stream >> package >> status >> error; | ||
879 | qDebug( "\tInstall Failed for package %s with error code %d and error message %s", | ||
880 | package.latin1(), status, error.latin1() ); | ||
881 | } else if ( message == "removeStarted(QString)" ) { | ||
882 | QString package; | ||
883 | stream >> package; | ||
884 | qDebug( "\tRemove Started for package %s", package.latin1() ); | ||
885 | } else if ( message == "removeDone(QString)" ) { | ||
886 | QString package; | ||
887 | stream >> package; | ||
888 | qDebug( "\tRemove Finished for package %s", package.latin1() ); | ||
889 | } else if ( message == "removeFailed(QString)" ) { | ||
890 | QString package; | ||
891 | stream >> package; | ||
892 | qDebug( "\tRemove Failed for package %s", package.latin1() ); | ||
893 | } | ||
894 | |||
895 | if ( qrr && qrr->waitingForMessages ) | ||
896 | qrr->desktopMessage( message, data ); | ||
897 | } | ||
898 | |||
899 | |||
900 | // This is only connected if QPE_HAVE_DIRECT_ACCESS is defined | ||
901 | void Server::runDirectAccess() | ||
902 | { | ||
903 | #ifdef QPE_HAVE_DIRECT_ACCESS | ||
904 | // The timer must have fired after all the apps responded | ||
905 | // with flushDone(). Just ignore it. | ||
906 | if ( directAccessRun ) | ||
907 | return; | ||
908 | |||
909 | directAccessRun = TRUE; | ||
910 | ::readyDirectAccess(cardInfoString(), installLocationsString()); | ||
911 | #endif | ||
912 | } | ||
913 | |||
914 | // This is only called if QPE_HAVE_DIRECT_ACCESS is defined | ||
915 | void Server::postDirectAccess() | ||
916 | { | ||
917 | #ifdef QPE_HAVE_DIRECT_ACCESS | ||
918 | qDebug( "Server::postDirectAccess()" ); | ||
919 | |||
920 | // Categories may have changed | ||
921 | QCopEnvelope e1( "QPE/System", "categoriesChanged()" ); | ||
922 | // Apps need to reload their data | ||
923 | QCopEnvelope e2( "QPE/System", "reload()" ); | ||
924 | // Reload DocLinks | ||
925 | docList->storageChanged(); | ||
926 | // Restart the PDA server stuff | ||
927 | startTransferServer(); | ||
928 | |||
929 | // restart the mtab monitor | ||
930 | #ifndef QT_NO_COP | ||
931 | { | ||
932 | QCopEnvelope e( "QPE/Stabmon", "restartMonitor()" ); | ||
933 | } | ||
934 | #endif | ||
935 | |||
936 | // Process queued requests | ||
937 | const char *queueFile = ::directAccessQueueFile(); | ||
938 | QFile *file = new QFile( queueFile ); | ||
939 | if ( !file->exists() ) { | ||
940 | delete file; | ||
941 | // Get rid of the dialog | ||
942 | if ( syncDialog ) { | ||
943 | delete syncDialog; | ||
944 | syncDialog = 0; | ||
945 | } | ||
946 | #warning FIXME support TempScreenSaverMode | ||
947 | #if 0 | ||
948 | QPEApplication::setTempScreenSaverMode(QPEApplication::Enable); | ||
949 | #endif | ||
950 | } else { | ||
951 | qrr = new QueuedRequestRunner( file, syncDialog ); | ||
952 | connect( qrr, SIGNAL(finished()), | ||
953 | this, SLOT(finishedQueuedRequests()) ); | ||
954 | QTimer::singleShot( 100, qrr, SLOT(process()) ); | ||
955 | // qrr will remove the sync dialog later | ||
956 | } | ||
957 | #endif | ||
958 | } | ||
959 | |||
960 | void Server::finishedQueuedRequests() | ||
961 | { | ||
962 | if ( qrr->readyToDelete ) { | ||
963 | delete qrr; | ||
964 | qrr = 0; | ||
965 | // Get rid of the dialog | ||
966 | if ( syncDialog ) { | ||
967 | delete syncDialog; | ||
968 | syncDialog = 0; | ||
969 | } | ||
970 | #warning FIXME support TempScreenSaverMode | ||
971 | #if 0 | ||
972 | QPEApplication::setTempScreenSaverMode(QPEApplication::Enable); | ||
973 | #endif | ||
974 | } else { | ||
975 | qrr->readyToDelete = TRUE; | ||
976 | QTimer::singleShot( 0, this, SLOT(finishedQueuedRequests()) ); | ||
977 | } | ||
978 | } | ||
979 | |||
diff --git a/core/launcher/server.h b/core/launcher/server.h index 1dc5e7e..d71d68a 100644 --- a/core/launcher/server.h +++ b/core/launcher/server.h | |||
@@ -37,6 +37,7 @@ class StorageInfo; | |||
37 | class SyncDialog; | 37 | class SyncDialog; |
38 | class DocumentList; | 38 | class DocumentList; |
39 | class ServerInterface; | 39 | class ServerInterface; |
40 | class QueuedRequestRunner; | ||
40 | namespace Opie { | 41 | namespace Opie { |
41 | namespace Core { | 42 | namespace Core { |
42 | class ODeviceButton; | 43 | class ODeviceButton; |
@@ -69,6 +70,9 @@ private slots: | |||
69 | void applicationConnected(const QString &app); | 70 | void applicationConnected(const QString &app); |
70 | void storageChanged(); | 71 | void storageChanged(); |
71 | void cancelSync(); | 72 | void cancelSync(); |
73 | void desktopMessage( const QCString &, const QByteArray & ); | ||
74 | void runDirectAccess(); | ||
75 | void finishedQueuedRequests(); | ||
72 | 76 | ||
73 | protected: | 77 | protected: |
74 | void styleChange( QStyle & ); | 78 | void styleChange( QStyle & ); |
@@ -78,6 +82,10 @@ private: | |||
78 | void layout(); | 82 | void layout(); |
79 | void startTransferServer(); | 83 | void startTransferServer(); |
80 | void preloadApps(); | 84 | void preloadApps(); |
85 | void prepareDirectAccess(); | ||
86 | void postDirectAccess(); | ||
87 | QString cardInfoString(); | ||
88 | QString installLocationsString(); | ||
81 | 89 | ||
82 | QCopBridge *qcopBridge; | 90 | QCopBridge *qcopBridge; |
83 | TransferServer *transferServer; | 91 | TransferServer *transferServer; |
@@ -92,6 +100,10 @@ private: | |||
92 | AppLauncher *appLauncher; | 100 | AppLauncher *appLauncher; |
93 | DocumentList *docList; | 101 | DocumentList *docList; |
94 | ServerInterface *serverGui; | 102 | ServerInterface *serverGui; |
103 | |||
104 | int pendingFlushes; | ||
105 | bool directAccessRun; | ||
106 | QueuedRequestRunner *qrr; | ||
95 | }; | 107 | }; |
96 | 108 | ||
97 | 109 | ||
diff --git a/core/launcher/server.pro b/core/launcher/server.pro index f366f54..5f2aa02 100644 --- a/core/launcher/server.pro +++ b/core/launcher/server.pro | |||
@@ -5,6 +5,7 @@ CONFIG += qt warn_on | |||
5 | DESTDIR = $$(OPIEDIR)/bin | 5 | DESTDIR = $$(OPIEDIR)/bin |
6 | 6 | ||
7 | HEADERS += server.h \ | 7 | HEADERS += server.h \ |
8 | qrr.h \ | ||
8 | serverinterface.h \ | 9 | serverinterface.h \ |
9 | launchertab.h \ | 10 | launchertab.h \ |
10 | documentlist.h \ | 11 | documentlist.h \ |
@@ -34,6 +35,7 @@ HEADERS += server.h \ | |||
34 | mediadlg.h | 35 | mediadlg.h |
35 | 36 | ||
36 | SOURCES += server.cpp \ | 37 | SOURCES += server.cpp \ |
38 | qrr.cpp \ | ||
37 | serverinterface.cpp \ | 39 | serverinterface.cpp \ |
38 | launchertab.cpp \ | 40 | launchertab.cpp \ |
39 | documentlist.cpp \ | 41 | documentlist.cpp \ |
@@ -77,6 +79,9 @@ DEPENDPATH += $(OPIEDIR)/noncore/settings/mediummount | |||
77 | LIBS += -lqpe -lopiecore2 -lopieui2 -lopiesecurity2 -lqrsync | 79 | LIBS += -lqpe -lopiecore2 -lopieui2 -lopiesecurity2 -lqrsync |
78 | TARGET = qpe | 80 | TARGET = qpe |
79 | 81 | ||
82 | ## not ready for use yet | ||
83 | # DEFINES += QPE_HAVE_DIRECT_ACCESS | ||
84 | |||
80 | contains( $(CONFIG_TARGET_MACOSX), y ) { | 85 | contains( $(CONFIG_TARGET_MACOSX), y ) { |
81 | LIBS += -lcrypt | 86 | LIBS += -lcrypt |
82 | } | 87 | } |
diff --git a/core/launcher/serverapp.cpp b/core/launcher/serverapp.cpp index 66cc788..fac52a6 100644 --- a/core/launcher/serverapp.cpp +++ b/core/launcher/serverapp.cpp | |||
@@ -60,11 +60,13 @@ static int loggedin=0; | |||
60 | QCopKeyRegister::QCopKeyRegister() | 60 | QCopKeyRegister::QCopKeyRegister() |
61 | : m_keyCode( 0 ) | 61 | : m_keyCode( 0 ) |
62 | { | 62 | { |
63 | odebug << "KeyRegister1 " << m_keyCode << oendl; | ||
63 | } | 64 | } |
64 | 65 | ||
65 | QCopKeyRegister::QCopKeyRegister( int k, const QCString& c, const QCString& m ) | 66 | QCopKeyRegister::QCopKeyRegister( int k, const QCString& c, const QCString& m ) |
66 | :m_keyCode( k ), m_channel( c ), m_message( m ) | 67 | :m_keyCode( k ), m_channel( c ), m_message( m ) |
67 | { | 68 | { |
69 | odebug << "keyRegister2 " << m_keyCode << c << m << oendl; | ||
68 | } | 70 | } |
69 | 71 | ||
70 | int QCopKeyRegister::keyCode() const | 72 | int QCopKeyRegister::keyCode() const |
@@ -86,8 +88,8 @@ bool QCopKeyRegister::send() | |||
86 | { | 88 | { |
87 | if (m_channel.isNull() ) | 89 | if (m_channel.isNull() ) |
88 | return false; | 90 | return false; |
89 | 91 | qDebug("Send Message: "+m_channel+" "+m_message); | |
90 | QCopEnvelope( m_channel, m_message ); | 92 | QCopEnvelope e( m_channel, m_message ); |
91 | 93 | ||
92 | return true; | 94 | return true; |
93 | } | 95 | } |
@@ -165,6 +167,7 @@ void KeyFilter::timerEvent(QTimerEvent* e) | |||
165 | 167 | ||
166 | void KeyFilter::registerKey( const QCopKeyRegister& key ) | 168 | void KeyFilter::registerKey( const QCopKeyRegister& key ) |
167 | { | 169 | { |
170 | odebug << "KeyFilter::registerKey " << key.keyCode() << key.channel() << key.message() << oendl; | ||
168 | m_keys.insert( key.keyCode(), key ); | 171 | m_keys.insert( key.keyCode(), key ); |
169 | } | 172 | } |
170 | 173 | ||