summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcherview.cpp5
-rw-r--r--core/launcher/transferserver.cpp2
2 files changed, 4 insertions, 3 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index 2a051a6..95a1d4a 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -1,182 +1,183 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 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 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 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 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. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "launcherview.h" 21#include "launcherview.h"
22 22
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <qpe/applnk.h> 24#include <qpe/applnk.h>
25#include <qpe/qpedebug.h> 25#include <qpe/qpedebug.h>
26#include <qpe/categories.h> 26#include <qpe/categories.h>
27#include <qpe/categoryselect.h> 27#include <qpe/categoryselect.h>
28#include <qpe/menubutton.h> 28#include <qpe/menubutton.h>
29#include <qpe/mimetype.h> 29#include <qpe/mimetype.h>
30#include <qpe/resource.h> 30#include <qpe/resource.h>
31#include <qpe/qpetoolbar.h> 31#include <qpe/qpetoolbar.h>
32//#include <qtopia/private/palmtoprecord.h> 32//#include <qtopia/private/palmtoprecord.h>
33 33
34#include <qtimer.h> 34#include <qtimer.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qdict.h> 36#include <qdict.h>
37#include <qfile.h> 37#include <qfile.h>
38#include <qfileinfo.h> 38#include <qfileinfo.h>
39#include <qhbox.h> 39#include <qhbox.h>
40#include <qiconview.h> 40#include <qiconview.h>
41#include <qpainter.h> 41#include <qpainter.h>
42#include <qregexp.h> 42#include <qregexp.h>
43#include <qtoolbutton.h> 43#include <qtoolbutton.h>
44#include <qimage.h> 44#include <qimage.h>
45 45
46#include <cstdlib>
46 47
47class BgPixmap 48class BgPixmap
48{ 49{
49public: 50public:
50 BgPixmap( const QPixmap &p ) : pm(p), ref(1) {} 51 BgPixmap( const QPixmap &p ) : pm(p), ref(1) {}
51 QPixmap pm; 52 QPixmap pm;
52 int ref; 53 int ref;
53}; 54};
54 55
55enum BusyIndicatorType { 56enum BusyIndicatorType {
56 BIT_Normal = 0, 57 BIT_Normal = 0,
57 BIT_Blinking 58 BIT_Blinking
58}; 59};
59 60
60static QMap<QString,BgPixmap*> *bgCache = 0; 61static QMap<QString,BgPixmap*> *bgCache = 0;
61 62
62class LauncherIconView : public QIconView { 63class LauncherIconView : public QIconView {
63public: 64public:
64 LauncherIconView( QWidget* parent, const char* name=0 ) : 65 LauncherIconView( QWidget* parent, const char* name=0 ) :
65 QIconView(parent,name), 66 QIconView(parent,name),
66 tf(""), 67 tf(""),
67 cf(0), 68 cf(0),
68 bsy(0), 69 bsy(0),
69 bigIcns(TRUE), 70 bigIcns(TRUE),
70 bgColor(white) 71 bgColor(white)
71 { 72 {
72 sortmeth = Name; 73 sortmeth = Name;
73 hidden.setAutoDelete(TRUE); 74 hidden.setAutoDelete(TRUE);
74 ike = FALSE; 75 ike = FALSE;
75 busytimer = 0; 76 busytimer = 0;
76 calculateGrid( Bottom ); 77 calculateGrid( Bottom );
77 } 78 }
78 79
79 ~LauncherIconView() 80 ~LauncherIconView()
80 { 81 {
81#if 0 // debuggery 82#if 0 // debuggery
82 QListIterator<AppLnk> it(hidden); 83 QListIterator<AppLnk> it(hidden);
83 AppLnk* l; 84 AppLnk* l;
84 while ((l=it.current())) { 85 while ((l=it.current())) {
85 ++it; 86 ++it;
86 //qDebug("%p: hidden (should remove)",l); 87 //qDebug("%p: hidden (should remove)",l);
87 } 88 }
88#endif 89#endif
89 } 90 }
90 91
91 void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } 92 void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; }
92 93
93 QPixmap* busyPixmap() const { return (QPixmap*)&bpm[::abs(busystate)]; } 94 QPixmap* busyPixmap() const { return (QPixmap*)&bpm[abs(busystate)]; }
94 QIconViewItem* busyItem() const { return bsy; } 95 QIconViewItem* busyItem() const { return bsy; }
95 void setBigIcons( bool bi ) { bigIcns = bi; } 96 void setBigIcons( bool bi ) { bigIcns = bi; }
96 97
97 void updateCategoriesAndMimeTypes(); 98 void updateCategoriesAndMimeTypes();
98 99
99 void doAutoScroll() 100 void doAutoScroll()
100 { 101 {
101 // We don't want rubberbanding (yet) 102 // We don't want rubberbanding (yet)
102 } 103 }
103 104
104 void setBusy(bool on) 105 void setBusy(bool on)
105 { 106 {
106 QIconViewItem *c = on ? currentItem() : 0; 107 QIconViewItem *c = on ? currentItem() : 0;
107 108
108 if ( bsy != c ) { 109 if ( bsy != c ) {
109 QIconViewItem *oldbsy = bsy; 110 QIconViewItem *oldbsy = bsy;
110 bsy = c; 111 bsy = c;
111 112
112 if ( oldbsy ) 113 if ( oldbsy )
113 oldbsy-> repaint ( ); 114 oldbsy-> repaint ( );
114 115
115 if ( busytimer ) { 116 if ( busytimer ) {
116 killTimer ( busytimer ); 117 killTimer ( busytimer );
117 busytimer = 0; 118 busytimer = 0;
118 } 119 }
119 120
120 if ( bsy ) { 121 if ( bsy ) {
121 QPixmap *src = bsy-> QIconViewItem::pixmap(); 122 QPixmap *src = bsy-> QIconViewItem::pixmap();
122 for ( int i = 0; i <= 5; i++ ) { 123 for ( int i = 0; i <= 5; i++ ) {
123 QImage img = src->convertToImage(); 124 QImage img = src->convertToImage();
124 QRgb* rgb; 125 QRgb* rgb;
125 int count; 126 int count;
126 if ( img.depth() == 32 ) { 127 if ( img.depth() == 32 ) {
127 rgb = (QRgb*)img.bits(); 128 rgb = (QRgb*)img.bits();
128 count = img.bytesPerLine()/sizeof(QRgb)*img.height(); 129 count = img.bytesPerLine()/sizeof(QRgb)*img.height();
129 } else { 130 } else {
130 rgb = img.colorTable(); 131 rgb = img.colorTable();
131 count = img.numColors(); 132 count = img.numColors();
132 } 133 }
133 int rc, gc, bc; 134 int rc, gc, bc;
134 int bs = ::abs ( i * 10 ) + 25; 135 int bs = abs ( i * 10 ) + 25;
135 colorGroup().highlight().rgb( &rc, &gc, &bc ); 136 colorGroup().highlight().rgb( &rc, &gc, &bc );
136 rc = rc * bs / 100; 137 rc = rc * bs / 100;
137 gc = gc * bs / 100; 138 gc = gc * bs / 100;
138 bc = bc * bs / 100; 139 bc = bc * bs / 100;
139 140
140 for ( int r = 0; r < count; r++, rgb++ ) { 141 for ( int r = 0; r < count; r++, rgb++ ) {
141 int ri = rc + qRed ( *rgb ) * ( 100 - bs ) / 100; 142 int ri = rc + qRed ( *rgb ) * ( 100 - bs ) / 100;
142 int gi = gc + qGreen ( *rgb ) * ( 100 - bs ) / 100; 143 int gi = gc + qGreen ( *rgb ) * ( 100 - bs ) / 100;
143 int bi = bc + qBlue ( *rgb ) * ( 100 - bs ) / 100; 144 int bi = bc + qBlue ( *rgb ) * ( 100 - bs ) / 100;
144 int ai = qAlpha ( *rgb ); 145 int ai = qAlpha ( *rgb );
145 *rgb = qRgba ( ri, gi, bi, ai ); 146 *rgb = qRgba ( ri, gi, bi, ai );
146 } 147 }
147 148
148 bpm [i].convertFromImage( img ); 149 bpm [i].convertFromImage( img );
149 } 150 }
150 151
151 if ( busyType == BIT_Blinking ) { 152 if ( busyType == BIT_Blinking ) {
152 busystate = 0; 153 busystate = 0;
153 busytimer = startTimer ( 200 ); 154 busytimer = startTimer ( 200 );
154 } 155 }
155 else { 156 else {
156 busystate = 3; 157 busystate = 3;
157 } 158 }
158 timerEvent ( 0 ); 159 timerEvent ( 0 );
159 } 160 }
160 } 161 }
161 } 162 }
162 163
163 virtual void timerEvent ( QTimerEvent *te ) 164 virtual void timerEvent ( QTimerEvent *te )
164 { 165 {
165 if ( !te || ( te-> timerId ( ) == busytimer )) { 166 if ( !te || ( te-> timerId ( ) == busytimer )) {
166 if ( bsy ) { 167 if ( bsy ) {
167 busystate++; 168 busystate++;
168 if ( busystate > 5 ) 169 if ( busystate > 5 )
169 busystate = -4; 170 busystate = -4;
170 171
171 QScrollView::updateContents ( bsy-> pixmapRect ( false )); 172 QScrollView::updateContents ( bsy-> pixmapRect ( false ));
172 } 173 }
173 } 174 }
174 } 175 }
175 176
176 bool inKeyEvent() const { return ike; } 177 bool inKeyEvent() const { return ike; }
177 void keyPressEvent(QKeyEvent* e) 178 void keyPressEvent(QKeyEvent* e)
178 { 179 {
179 ike = TRUE; 180 ike = TRUE;
180 if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) 181 if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space )
181 returnPressed(currentItem()); 182 returnPressed(currentItem());
182 QIconView::keyPressEvent(e); 183 QIconView::keyPressEvent(e);
diff --git a/core/launcher/transferserver.cpp b/core/launcher/transferserver.cpp
index aaa4425..cbda247 100644
--- a/core/launcher/transferserver.cpp
+++ b/core/launcher/transferserver.cpp
@@ -949,97 +949,97 @@ void ServerPI::newConnection( int socket )
949 if ( backupRestoreGzip( waitfile, targets ) ) 949 if ( backupRestoreGzip( waitfile, targets ) )
950 dtp->sendGzipFile( waitfile, targets ); 950 dtp->sendGzipFile( waitfile, targets );
951 else 951 else
952 dtp->sendFile( waitfile ); 952 dtp->sendFile( waitfile );
953 dtp->setSocket( socket ); 953 dtp->setSocket( socket );
954 } 954 }
955 else if ( wait[RetrieveFile] ) { 955 else if ( wait[RetrieveFile] ) {
956 qDebug("check retrieve file"); 956 qDebug("check retrieve file");
957 if ( backupRestoreGzip( waitfile ) ) 957 if ( backupRestoreGzip( waitfile ) )
958 dtp->retrieveGzipFile( waitfile ); 958 dtp->retrieveGzipFile( waitfile );
959 else 959 else
960 dtp->retrieveFile( waitfile ); 960 dtp->retrieveFile( waitfile );
961 dtp->setSocket( socket ); 961 dtp->setSocket( socket );
962 } 962 }
963 else if ( wait[SendByteArray] ) { 963 else if ( wait[SendByteArray] ) {
964 dtp->sendByteArray( waitarray ); 964 dtp->sendByteArray( waitarray );
965 dtp->setSocket( socket ); 965 dtp->setSocket( socket );
966 } 966 }
967 else if ( wait[RetrieveByteArray] ) { 967 else if ( wait[RetrieveByteArray] ) {
968 qDebug("retrieve byte array"); 968 qDebug("retrieve byte array");
969 dtp->retrieveByteArray(); 969 dtp->retrieveByteArray();
970 dtp->setSocket( socket ); 970 dtp->setSocket( socket );
971 } 971 }
972 else 972 else
973 waitsocket = socket; 973 waitsocket = socket;
974 974
975 for( int i = 0; i < 4; i++ ) 975 for( int i = 0; i < 4; i++ )
976 wait[i] = FALSE; 976 wait[i] = FALSE;
977} 977}
978 978
979QString ServerPI::absFilePath( const QString& file ) 979QString ServerPI::absFilePath( const QString& file )
980{ 980{
981 if ( file.isEmpty() ) return file; 981 if ( file.isEmpty() ) return file;
982 982
983 QString filepath( file ); 983 QString filepath( file );
984 if ( file[0] != "/" ) 984 if ( file[0] != "/" )
985 filepath = directory.path() + "/" + file; 985 filepath = directory.path() + "/" + file;
986 986
987 return filepath; 987 return filepath;
988} 988}
989 989
990 990
991void ServerPI::timerEvent( QTimerEvent * ) 991void ServerPI::timerEvent( QTimerEvent * )
992{ 992{
993 connectionClosed(); 993 connectionClosed();
994} 994}
995 995
996 996
997ServerDTP::ServerDTP( QObject *parent = 0, const char* name = 0) 997ServerDTP::ServerDTP( QObject *parent, const char* name)
998 : QSocket( parent, name ), mode( Idle ), createTargzProc( 0 ), 998 : QSocket( parent, name ), mode( Idle ), createTargzProc( 0 ),
999retrieveTargzProc( 0 ), gzipProc( 0 ) 999retrieveTargzProc( 0 ), gzipProc( 0 )
1000{ 1000{
1001 1001
1002 connect( this, SIGNAL( connected() ), SLOT( connected() ) ); 1002 connect( this, SIGNAL( connected() ), SLOT( connected() ) );
1003 connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); 1003 connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) );
1004 connect( this, SIGNAL( bytesWritten( int ) ), SLOT( bytesWritten( int ) ) ); 1004 connect( this, SIGNAL( bytesWritten( int ) ), SLOT( bytesWritten( int ) ) );
1005 connect( this, SIGNAL( readyRead() ), SLOT( readyRead() ) ); 1005 connect( this, SIGNAL( readyRead() ), SLOT( readyRead() ) );
1006 1006
1007 gzipProc = new QProcess( this, "gzipProc" ); 1007 gzipProc = new QProcess( this, "gzipProc" );
1008 gzipProc->setCommunication( QProcess::Stdin | QProcess::Stdout ); 1008 gzipProc->setCommunication( QProcess::Stdin | QProcess::Stdout );
1009 1009
1010 createTargzProc = new QProcess( QString("tar"), this, "createTargzProc"); 1010 createTargzProc = new QProcess( QString("tar"), this, "createTargzProc");
1011 createTargzProc->setCommunication( QProcess::Stdout ); 1011 createTargzProc->setCommunication( QProcess::Stdout );
1012 createTargzProc->setWorkingDirectory( QDir::rootDirPath() ); 1012 createTargzProc->setWorkingDirectory( QDir::rootDirPath() );
1013 connect( createTargzProc, SIGNAL( processExited() ), SLOT( targzDone() ) ); 1013 connect( createTargzProc, SIGNAL( processExited() ), SLOT( targzDone() ) );
1014 1014
1015 QStringList args = "tar"; 1015 QStringList args = "tar";
1016 args += "-xv"; 1016 args += "-xv";
1017 retrieveTargzProc = new QProcess( args, this, "retrieveTargzProc" ); 1017 retrieveTargzProc = new QProcess( args, this, "retrieveTargzProc" );
1018 retrieveTargzProc->setCommunication( QProcess::Stdin ); 1018 retrieveTargzProc->setCommunication( QProcess::Stdin );
1019 retrieveTargzProc->setWorkingDirectory( QDir::rootDirPath() ); 1019 retrieveTargzProc->setWorkingDirectory( QDir::rootDirPath() );
1020 connect( retrieveTargzProc, SIGNAL( processExited() ), 1020 connect( retrieveTargzProc, SIGNAL( processExited() ),
1021 SIGNAL( completed() ) ); 1021 SIGNAL( completed() ) );
1022 connect( retrieveTargzProc, SIGNAL( processExited() ), 1022 connect( retrieveTargzProc, SIGNAL( processExited() ),
1023 SLOT( extractTarDone() ) ); 1023 SLOT( extractTarDone() ) );
1024} 1024}
1025 1025
1026ServerDTP::~ServerDTP() 1026ServerDTP::~ServerDTP()
1027{ 1027{
1028 buf.close(); 1028 buf.close();
1029 file.close(); 1029 file.close();
1030 createTargzProc->kill(); 1030 createTargzProc->kill();
1031} 1031}
1032 1032
1033void ServerDTP::extractTarDone() 1033void ServerDTP::extractTarDone()
1034{ 1034{
1035 qDebug("extract done"); 1035 qDebug("extract done");
1036#ifndef QT_NO_COP 1036#ifndef QT_NO_COP
1037 QCopEnvelope e( "QPE/Desktop", "restoreDone(QString)" ); 1037 QCopEnvelope e( "QPE/Desktop", "restoreDone(QString)" );
1038 e << file.name(); 1038 e << file.name();
1039#endif 1039#endif
1040} 1040}
1041 1041
1042void ServerDTP::connected() 1042void ServerDTP::connected()
1043{ 1043{
1044 // send file mode 1044 // send file mode
1045 switch ( mode ) { 1045 switch ( mode ) {