Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

launcherglobal.cpp

Go to the documentation of this file.
00001 /*
00002  * GPLv2 only
00003  *
00004  * TT 2002-2002,2003
00005  */
00006 #include <qfile.h>
00007 #include <qtextstream.h>
00008 
00009 #include <qtopia/mimetype.h>
00010 
00011 #include "launcherglobal.h"
00012 
00013 bool Opie::Global::isAppLnkFileName( const QString& file ) {
00014     if ( file.right(1) == "/" )
00015         return FALSE;
00016 
00017     return file.find(MimeType::appsFolderName()+"/")==0;
00018 }
00019 
00020 QString Opie::Global::tempDir() {
00021     return QString::fromLatin1("/tmp/");
00022 }
00023 
00024 Global::Command* Opie::Global::builtinCommands() {
00025     return builtin;
00026 }
00027 
00028 QGuardedPtr<QWidget>* Opie::Global::builtinRunning() {
00029     return running;
00030 }
00031 
00032 QString Opie::Global::uuid() {
00033     QFile file( "/proc/sys/kernel/random/uuid" );
00034     if (!file.open(IO_ReadOnly ) )
00035         return QString::null;
00036 
00037     QTextStream stream(&file);
00038 
00039     return "{" + stream.read().stripWhiteSpace() + "}";
00040 }
00041 
00042 QByteArray Opie::Global::encodeBase64(const QByteArray& origData ) {
00043 // follows simple algorithm from rsync code
00044     uchar *in = (uchar*)origData.data();
00045 
00046     int inbytes = origData.size();
00047     int outbytes = ((inbytes * 8) + 5) / 6;
00048     int padding = 4-outbytes%4; if ( padding == 4 ) padding = 0;
00049 
00050     QByteArray outbuf(outbytes+padding);
00051     uchar* out = (uchar*)outbuf.data();
00052 
00053     const char *b64 =
00054         "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
00055 
00056     for (int i = 0; i < outbytes; i++) {
00057         int byte = (i * 6) / 8;
00058         int bit = (i * 6) % 8;
00059         if (bit < 3) {
00060             if (byte < inbytes)
00061                 *out = (b64[(in[byte] >> (2 - bit)) & 0x3F]);
00062         } else {
00063             if (byte + 1 == inbytes) {
00064                 *out = (b64[(in[byte] << (bit - 2)) & 0x3F]);
00065             } else {
00066                 *out = (b64[(in[byte] << (bit - 2) |
00067                      in[byte + 1] >> (10 - bit)) & 0x3F]);
00068             }
00069         }
00070         ++out;
00071     }
00072     ASSERT(out == (uchar*)outbuf.data() + outbuf.size() - padding);
00073     while ( padding-- )
00074         *out++='=';
00075 
00076     return outbuf;
00077 }
00078 
00079 

Generated on Sat Nov 5 16:15:30 2005 for OPIE by  doxygen 1.4.2