-rw-r--r-- | core/launcher/launcher.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index 767efb2..6764338 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp | |||
@@ -993,261 +993,268 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data) | |||
993 | * so wee need to fake at least 1.4 to be able | 993 | * so wee need to fake at least 1.4 to be able |
994 | * to sync with QtopiaDesktop1.6 | 994 | * to sync with QtopiaDesktop1.6 |
995 | */ | 995 | */ |
996 | else if ( msg == "sendVersionInfo()" ) { | 996 | else if ( msg == "sendVersionInfo()" ) { |
997 | QCopEnvelope e( "QPE/Desktop", "versionInfo(QString)" ); | 997 | QCopEnvelope e( "QPE/Desktop", "versionInfo(QString)" ); |
998 | QString v2 = QString::fromLatin1("1.4"); | 998 | QString v2 = QString::fromLatin1("1.4"); |
999 | e << v2; | 999 | e << v2; |
1000 | //qDebug("version %s\n", line.latin1()); | 1000 | //qDebug("version %s\n", line.latin1()); |
1001 | } else if ( msg == "sendCardInfo()" ) { | 1001 | } else if ( msg == "sendCardInfo()" ) { |
1002 | #ifndef QT_NO_COP | 1002 | #ifndef QT_NO_COP |
1003 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); | 1003 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); |
1004 | #endif | 1004 | #endif |
1005 | const QList<FileSystem> &fs = storage->fileSystems(); | 1005 | const QList<FileSystem> &fs = storage->fileSystems(); |
1006 | QListIterator<FileSystem> it ( fs ); | 1006 | QListIterator<FileSystem> it ( fs ); |
1007 | QString s; | 1007 | QString s; |
1008 | QString homeDir = getenv("HOME"); | 1008 | QString homeDir = getenv("HOME"); |
1009 | QString hardDiskHome, hardDiskHomePath; | 1009 | QString hardDiskHome, hardDiskHomePath; |
1010 | for ( ; it.current(); ++it ) { | 1010 | for ( ; it.current(); ++it ) { |
1011 | int k4 = (*it)->blockSize()/256; | 1011 | int k4 = (*it)->blockSize()/256; |
1012 | if ( (*it)->isRemovable() || (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs") { | 1012 | if ( (*it)->isRemovable() || (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs") { |
1013 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " | 1013 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " |
1014 | + QString::number( (*it)->availBlocks() * k4/4 ) | 1014 | + QString::number( (*it)->availBlocks() * k4/4 ) |
1015 | + "K " + (*it)->options() + ";"; | 1015 | + "K " + (*it)->options() + ";"; |
1016 | } else if ( (*it)->disk() == "/dev/mtdblock1" || | 1016 | } else if ( (*it)->disk() == "/dev/mtdblock1" || |
1017 | (*it)->disk() == "/dev/mtdblock/1" ) { | 1017 | (*it)->disk() == "/dev/mtdblock/1" ) { |
1018 | s += (*it)->name() + "=" + homeDir + "/Documents " | 1018 | s += (*it)->name() + "=" + homeDir + "/Documents " |
1019 | + QString::number( (*it)->availBlocks() * k4/4 ) | 1019 | + QString::number( (*it)->availBlocks() * k4/4 ) |
1020 | + "K " + (*it)->options() + ";"; | 1020 | + "K " + (*it)->options() + ";"; |
1021 | } else if ( (*it)->name().contains( "Hard Disk") && | 1021 | } else if ( (*it)->name().contains( "Hard Disk") && |
1022 | homeDir.contains( (*it)->path() ) && | 1022 | homeDir.contains( (*it)->path() ) && |
1023 | (*it)->path().length() > hardDiskHomePath.length() ) { | 1023 | (*it)->path().length() > hardDiskHomePath.length() ) { |
1024 | hardDiskHomePath = (*it)->path(); | 1024 | hardDiskHomePath = (*it)->path(); |
1025 | hardDiskHome = | 1025 | hardDiskHome = |
1026 | (*it)->name() + "=" + homeDir + "/Documents " | 1026 | (*it)->name() + "=" + homeDir + "/Documents " |
1027 | + QString::number( (*it)->availBlocks() * k4/4 ) | 1027 | + QString::number( (*it)->availBlocks() * k4/4 ) |
1028 | + "K " + (*it)->options() + ";"; | 1028 | + "K " + (*it)->options() + ";"; |
1029 | } | 1029 | } |
1030 | } | 1030 | } |
1031 | if ( !hardDiskHome.isEmpty() ) | 1031 | if ( !hardDiskHome.isEmpty() ) |
1032 | s += hardDiskHome; | 1032 | s += hardDiskHome; |
1033 | 1033 | ||
1034 | #ifndef QT_NO_COP | 1034 | #ifndef QT_NO_COP |
1035 | e << s; | 1035 | e << s; |
1036 | #endif | 1036 | #endif |
1037 | } else if ( msg == "sendSyncDate(QString)" ) { | 1037 | } else if ( msg == "sendSyncDate(QString)" ) { |
1038 | QString app; | 1038 | QString app; |
1039 | stream >> app; | 1039 | stream >> app; |
1040 | Config cfg( "qpe" ); | 1040 | Config cfg( "qpe" ); |
1041 | cfg.setGroup("SyncDate"); | 1041 | cfg.setGroup("SyncDate"); |
1042 | #ifndef QT_NO_COP | 1042 | #ifndef QT_NO_COP |
1043 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); | 1043 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); |
1044 | e << app << cfg.readEntry( app ); | 1044 | e << app << cfg.readEntry( app ); |
1045 | #endif | 1045 | #endif |
1046 | //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), | 1046 | //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), |
1047 | //cfg.readEntry( app ).latin1() ); | 1047 | //cfg.readEntry( app ).latin1() ); |
1048 | } else if ( msg == "setSyncDate(QString,QString)" ) { | 1048 | } else if ( msg == "setSyncDate(QString,QString)" ) { |
1049 | QString app, date; | 1049 | QString app, date; |
1050 | stream >> app >> date; | 1050 | stream >> app >> date; |
1051 | Config cfg( "qpe" ); | 1051 | Config cfg( "qpe" ); |
1052 | cfg.setGroup("SyncDate"); | 1052 | cfg.setGroup("SyncDate"); |
1053 | cfg.writeEntry( app, date ); | 1053 | cfg.writeEntry( app, date ); |
1054 | //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); | 1054 | //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); |
1055 | } else if ( msg == "startSync(QString)" ) { | 1055 | } else if ( msg == "startSync(QString)" ) { |
1056 | QString what; | 1056 | QString what; |
1057 | stream >> what; | 1057 | stream >> what; |
1058 | delete syncDialog; syncDialog = 0; | 1058 | delete syncDialog; syncDialog = 0; |
1059 | syncDialog = new SyncDialog( this, "syncProgress", FALSE, | 1059 | syncDialog = new SyncDialog( this, "syncProgress", FALSE, |
1060 | WStyle_Tool | WStyle_Customize | | 1060 | WStyle_Tool | WStyle_Customize | |
1061 | Qt::WStyle_StaysOnTop ); | 1061 | Qt::WStyle_StaysOnTop ); |
1062 | syncDialog->showMaximized(); | 1062 | syncDialog->showMaximized(); |
1063 | syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); | 1063 | syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); |
1064 | connect( syncDialog->buttonCancel, SIGNAL( clicked() ), | 1064 | connect( syncDialog->buttonCancel, SIGNAL( clicked() ), |
1065 | SLOT( cancelSync() ) ); | 1065 | SLOT( cancelSync() ) ); |
1066 | } else if ( msg == "stopSync()") { | 1066 | } else if ( msg == "stopSync()") { |
1067 | delete syncDialog; syncDialog = 0; | 1067 | delete syncDialog; syncDialog = 0; |
1068 | } else if ( msg == "getAllDocLinks()" ) { | 1068 | } else if ( msg == "getAllDocLinks()" ) { |
1069 | loadDocs(); | 1069 | loadDocs(); |
1070 | 1070 | ||
1071 | QString contents; | 1071 | QString contents; |
1072 | 1072 | ||
1073 | //Categories cats; | 1073 | //Categories cats; |
1074 | for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) { | 1074 | for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) { |
1075 | DocLnk *doc = it.current(); | 1075 | DocLnk *doc = it.current(); |
1076 | QFileInfo fi( doc->file() ); | 1076 | QFileInfo fi( doc->file() ); |
1077 | if ( !fi.exists() ) | 1077 | if ( !fi.exists() ) |
1078 | continue; | 1078 | continue; |
1079 | 1079 | ||
1080 | bool fake = !doc->linkFileKnown(); | 1080 | bool fake = !doc->linkFileKnown(); |
1081 | if ( !fake ) { | 1081 | if ( !fake ) { |
1082 | QFile f( doc->linkFile() ); | 1082 | QFile f( doc->linkFile() ); |
1083 | if ( f.open( IO_ReadOnly ) ) { | 1083 | if ( f.open( IO_ReadOnly ) ) { |
1084 | QTextStream ts( &f ); | 1084 | QTextStream ts( &f ); |
1085 | ts.setEncoding( QTextStream::UnicodeUTF8 ); | 1085 | ts.setEncoding( QTextStream::UnicodeUTF8 ); |
1086 | contents += ts.read(); | 1086 | contents += ts.read(); |
1087 | f.close(); | 1087 | f.close(); |
1088 | } else | 1088 | } else |
1089 | fake = TRUE; | 1089 | fake = TRUE; |
1090 | } | 1090 | } |
1091 | if (fake) { | 1091 | if (fake) { |
1092 | contents += "[Desktop Entry]\n"; | 1092 | contents += "[Desktop Entry]\n"; |
1093 | contents += "Categories = " + // No tr | 1093 | contents += "Categories = " + // No tr |
1094 | // cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr | 1094 | // cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr |
1095 | Qtopia::Record::idsToString( doc->categories() ) + "\n"; | 1095 | Qtopia::Record::idsToString( doc->categories() ) + "\n"; |
1096 | contents += "Name = "+doc->name()+"\n"; // No tr | 1096 | contents += "Name = "+doc->name()+"\n"; // No tr |
1097 | contents += "Type = "+doc->type()+"\n"; // No tr | 1097 | contents += "Type = "+doc->type()+"\n"; // No tr |
1098 | } | 1098 | } |
1099 | contents += "File = "+doc->file()+"\n"; // No tr // (resolves path) | 1099 | contents += "File = "+doc->file()+"\n"; // No tr // (resolves path) |
1100 | contents += QString("Size = %1\n").arg( fi.size() ); // No tr | 1100 | contents += QString("Size = %1\n").arg( fi.size() ); // No tr |
1101 | } | 1101 | } |
1102 | 1102 | ||
1103 | //qDebug( "sending length %d", contents.length() ); | 1103 | //qDebug( "sending length %d", contents.length() ); |
1104 | #ifndef QT_NO_COP | 1104 | #ifndef QT_NO_COP |
1105 | QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); | 1105 | QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); |
1106 | e << contents; | 1106 | e << contents; |
1107 | #endif | 1107 | #endif |
1108 | 1108 | ||
1109 | //qDebug( "================ \n\n%s\n\n===============", | 1109 | //qDebug( "================ \n\n%s\n\n===============", |
1110 | //contents.latin1() ); | 1110 | //contents.latin1() ); |
1111 | 1111 | ||
1112 | delete docsFolder; | 1112 | delete docsFolder; |
1113 | docsFolder = 0; | 1113 | docsFolder = 0; |
1114 | #ifdef QWS | 1114 | #ifdef QWS |
1115 | } else if ( msg == "setMouseProto(QString)" ) { | 1115 | } else if ( msg == "setMouseProto(QString)" ) { |
1116 | QString mice; | 1116 | QString mice; |
1117 | stream >> mice; | 1117 | stream >> mice; |
1118 | setenv("QWS_MOUSE_PROTO",mice.latin1(),1); | 1118 | setenv("QWS_MOUSE_PROTO",mice.latin1(),1); |
1119 | qwsServer->openMouse(); | 1119 | qwsServer->openMouse(); |
1120 | } else if ( msg == "setKeyboard(QString)" ) { | 1120 | } else if ( msg == "setKeyboard(QString)" ) { |
1121 | QString kb; | 1121 | QString kb; |
1122 | stream >> kb; | 1122 | stream >> kb; |
1123 | setenv("QWS_KEYBOARD",kb.latin1(),1); | 1123 | setenv("QWS_KEYBOARD",kb.latin1(),1); |
1124 | qwsServer->openKeyboard(); | 1124 | qwsServer->openKeyboard(); |
1125 | #endif | 1125 | #endif |
1126 | } | 1126 | } |
1127 | } | 1127 | } |
1128 | 1128 | ||
1129 | void Launcher::cancelSync() | 1129 | void Launcher::cancelSync() |
1130 | { | 1130 | { |
1131 | #ifndef QT_NO_COP | 1131 | #ifndef QT_NO_COP |
1132 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); | 1132 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); |
1133 | #endif | 1133 | #endif |
1134 | } | 1134 | } |
1135 | 1135 | ||
1136 | void Launcher::launcherMessage( const QCString &msg, const QByteArray &data) | 1136 | void Launcher::launcherMessage( const QCString &msg, const QByteArray &data) |
1137 | { | 1137 | { |
1138 | QDataStream stream( data, IO_ReadOnly ); | 1138 | QDataStream stream( data, IO_ReadOnly ); |
1139 | if ( msg == "setTabView(QString,int)" ) { | 1139 | if ( msg == "setTabView(QString,int)" ) { |
1140 | QString id; | 1140 | QString id; |
1141 | stream >> id; | 1141 | stream >> id; |
1142 | int mode; | 1142 | int mode; |
1143 | stream >> mode; | 1143 | stream >> mode; |
1144 | if ( tabs->view(id) ) | 1144 | if ( tabs->view(id) ) |
1145 | tabs->view(id)->setViewMode( (LauncherView::ViewMode)mode ); | 1145 | tabs->view(id)->setViewMode( (LauncherView::ViewMode)mode ); |
1146 | } else if ( msg == "setTabBackground(QString,int,QString)" ) { | 1146 | } else if ( msg == "setTabBackground(QString,int,QString)" ) { |
1147 | QString id; | 1147 | QString id; |
1148 | stream >> id; | 1148 | stream >> id; |
1149 | int mode; | 1149 | int mode; |
1150 | stream >> mode; | 1150 | stream >> mode; |
1151 | QString pixmapOrColor; | 1151 | QString pixmapOrColor; |
1152 | stream >> pixmapOrColor; | 1152 | stream >> pixmapOrColor; |
1153 | if ( tabs->view(id) ) | 1153 | if ( tabs->view(id) ) |
1154 | tabs->view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); | 1154 | tabs->view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); |
1155 | } else if ( msg == "setTextColor(QString,QString)" ) { | 1155 | } else if ( msg == "setTextColor(QString,QString)" ) { |
1156 | QString id; | 1156 | QString id; |
1157 | stream >> id; | 1157 | stream >> id; |
1158 | QString color; | 1158 | QString color; |
1159 | stream >> color; | 1159 | stream >> color; |
1160 | if ( tabs->view(id) ) | 1160 | if ( tabs->view(id) ) |
1161 | tabs->view(id)->setTextColor( QColor(color) ); | 1161 | tabs->view(id)->setTextColor( QColor(color) ); |
1162 | } else if ( msg == "setFont(QString,QString,int,int,int)" ) { | 1162 | } else if ( msg == "setFont(QString,QString,int,int,int)" ) { |
1163 | QString id; | 1163 | QString id; |
1164 | stream >> id; | 1164 | stream >> id; |
1165 | QString fam; | 1165 | QString fam; |
1166 | stream >> fam; | 1166 | stream >> fam; |
1167 | int size; | 1167 | int size; |
1168 | stream >> size; | 1168 | stream >> size; |
1169 | int weight; | 1169 | int weight; |
1170 | stream >> weight; | 1170 | stream >> weight; |
1171 | int italic; | 1171 | int italic; |
1172 | stream >> italic; | 1172 | stream >> italic; |
1173 | if ( tabs->view(id) ) | 1173 | if ( tabs->view(id) ) |
1174 | if ( !fam. isEmpty ( )) | 1174 | if ( !fam. isEmpty ( )) |
1175 | tabs->view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); | 1175 | tabs->view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); |
1176 | else | 1176 | else |
1177 | tabs->view(id)->unsetViewFont(); | 1177 | tabs->view(id)->unsetViewFont(); |
1178 | qDebug( "setFont: %s, %d, %d, %d", fam.latin1(), size, weight, italic ); | 1178 | qDebug( "setFont: %s, %d, %d, %d", fam.latin1(), size, weight, italic ); |
1179 | } | 1179 | } |
1180 | else if ( msg == "setBusyIndicatorType(QString)" ) { | 1180 | else if ( msg == "setBusyIndicatorType(QString)" ) { |
1181 | QString type; | 1181 | QString type; |
1182 | stream >> type; | 1182 | stream >> type; |
1183 | tabs->setBusyIndicatorType(type); | 1183 | tabs->setBusyIndicatorType(type); |
1184 | } | 1184 | } |
1185 | else if ( msg == "home()" ) { | ||
1186 | if ( isVisibleWindow( winId ( ))) | ||
1187 | nextView ( ); | ||
1188 | else | ||
1189 | raise ( ); | ||
1190 | |||
1191 | } | ||
1185 | } | 1192 | } |
1186 | 1193 | ||
1187 | void Launcher::storageChanged() | 1194 | void Launcher::storageChanged() |
1188 | { | 1195 | { |
1189 | if ( in_lnk_props ) { | 1196 | if ( in_lnk_props ) { |
1190 | got_lnk_change = TRUE; | 1197 | got_lnk_change = TRUE; |
1191 | lnk_change = QString::null; | 1198 | lnk_change = QString::null; |
1192 | } else { | 1199 | } else { |
1193 | updateLink( QString::null ); | 1200 | updateLink( QString::null ); |
1194 | } | 1201 | } |
1195 | } | 1202 | } |
1196 | 1203 | ||
1197 | 1204 | ||
1198 | bool Launcher::mkdir(const QString &localPath) | 1205 | bool Launcher::mkdir(const QString &localPath) |
1199 | { | 1206 | { |
1200 | QDir fullDir(localPath); | 1207 | QDir fullDir(localPath); |
1201 | if (fullDir.exists()) | 1208 | if (fullDir.exists()) |
1202 | return true; | 1209 | return true; |
1203 | 1210 | ||
1204 | // at this point the directory doesn't exist | 1211 | // at this point the directory doesn't exist |
1205 | // go through the directory tree and start creating the direcotories | 1212 | // go through the directory tree and start creating the direcotories |
1206 | // that don't exist; if we can't create the directories, return false | 1213 | // that don't exist; if we can't create the directories, return false |
1207 | 1214 | ||
1208 | QString dirSeps = "/"; | 1215 | QString dirSeps = "/"; |
1209 | int dirIndex = localPath.find(dirSeps); | 1216 | int dirIndex = localPath.find(dirSeps); |
1210 | QString checkedPath; | 1217 | QString checkedPath; |
1211 | 1218 | ||
1212 | // didn't find any seps; weird, use the cur dir instead | 1219 | // didn't find any seps; weird, use the cur dir instead |
1213 | if (dirIndex == -1) { | 1220 | if (dirIndex == -1) { |
1214 | //qDebug("No seperators found in path %s", localPath.latin1()); | 1221 | //qDebug("No seperators found in path %s", localPath.latin1()); |
1215 | checkedPath = QDir::currentDirPath(); | 1222 | checkedPath = QDir::currentDirPath(); |
1216 | } | 1223 | } |
1217 | 1224 | ||
1218 | while (checkedPath != localPath) { | 1225 | while (checkedPath != localPath) { |
1219 | // no more seperators found, use the local path | 1226 | // no more seperators found, use the local path |
1220 | if (dirIndex == -1) | 1227 | if (dirIndex == -1) |
1221 | checkedPath = localPath; | 1228 | checkedPath = localPath; |
1222 | else { | 1229 | else { |
1223 | // the next directory to check | 1230 | // the next directory to check |
1224 | checkedPath = localPath.left(dirIndex) + "/"; | 1231 | checkedPath = localPath.left(dirIndex) + "/"; |
1225 | // advance the iterator; the next dir seperator | 1232 | // advance the iterator; the next dir seperator |
1226 | dirIndex = localPath.find(dirSeps, dirIndex+1); | 1233 | dirIndex = localPath.find(dirSeps, dirIndex+1); |
1227 | } | 1234 | } |
1228 | 1235 | ||
1229 | QDir checkDir(checkedPath); | 1236 | QDir checkDir(checkedPath); |
1230 | if (!checkDir.exists()) { | 1237 | if (!checkDir.exists()) { |
1231 | //qDebug("mkdir making dir %s", checkedPath.latin1()); | 1238 | //qDebug("mkdir making dir %s", checkedPath.latin1()); |
1232 | 1239 | ||
1233 | if (!checkDir.mkdir(checkedPath)) { | 1240 | if (!checkDir.mkdir(checkedPath)) { |
1234 | qDebug("Unable to make directory %s", checkedPath.latin1()); | 1241 | qDebug("Unable to make directory %s", checkedPath.latin1()); |
1235 | return FALSE; | 1242 | return FALSE; |
1236 | } | 1243 | } |
1237 | } | 1244 | } |
1238 | 1245 | ||
1239 | } | 1246 | } |
1240 | return TRUE; | 1247 | return TRUE; |
1241 | } | 1248 | } |
1242 | 1249 | ||
1243 | void Launcher::preloadApps() | 1250 | void Launcher::preloadApps() |
1244 | { | 1251 | { |
1245 | Config cfg("Launcher"); | 1252 | Config cfg("Launcher"); |
1246 | cfg.setGroup("Preload"); | 1253 | cfg.setGroup("Preload"); |
1247 | QStringList apps = cfg.readListEntry("Apps",','); | 1254 | QStringList apps = cfg.readListEntry("Apps",','); |
1248 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { | 1255 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { |
1249 | #ifndef QT_NO_COP | 1256 | #ifndef QT_NO_COP |
1250 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); | 1257 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); |
1251 | #endif | 1258 | #endif |
1252 | } | 1259 | } |
1253 | } | 1260 | } |