00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifdef USE_QT
00019 #include <qevent.h>
00020 #include <qapplication.h>
00021 #endif
00022
00023 #include <time.h>
00024 #include <stdio.h>
00025 #include <string.h>
00026 #include <stdint.h>
00027 #include <sys/types.h>
00028 #include <unistd.h>
00029 #include <errno.h>
00030 #include <sys/stat.h>
00031
00032 #include "common.h"
00033
00034 #ifdef USE_QT
00035
00036
00037
00038 void sendMsg( QString title, QString msg, RioMMInterface *rio )
00039 {
00040 #ifndef RIO_EMUL
00041 QCustomEvent *event;
00042 PLAYDATA *playData;
00043
00044 playData = new PLAYDATA;
00045 playData->id = 1;
00046 playData->object = NULL;
00047 playData->size = 0;
00048 playData->title = new QString( title );
00049 playData->msg = new QString( msg );
00050 event = new QCustomEvent( (QEvent::Type)(QEvent::User + 1), playData );
00051 QApplication::postEvent( (QObject*)rio, event );
00052 #else
00053 qWarning( "%s\n", msg.ascii() );
00054 exit( -1 );
00055 #endif
00056 }
00057
00058 #ifdef USE_GRID
00059 void showMessageBox( QString title, QString msg, RioMMInterface *rio )
00060 {
00061
00062 QCustomEvent *event;
00063
00064 PLAYDATA *playData;
00065
00066
00067
00068
00069
00070 playData = new PLAYDATA;
00071 playData->id = 0;
00072 playData->object = NULL;
00073 playData->size = 0;
00074 playData->title = new QString( title );
00075 playData->msg = new QString( msg );
00076
00077
00078 event = new QCustomEvent( (QEvent::Type)(QEvent::User + 8), playData );
00079
00080 QApplication::postEvent( (QObject*)rio, event );
00081 }
00082
00083 void hideMessageBox( RioMMInterface *rio )
00084 {
00085
00086 QCustomEvent *event;
00087
00088 PLAYDATA *playData;
00089
00090
00091
00092
00093
00094
00095 playData = new PLAYDATA;
00096 playData->id = 1;
00097 playData->object = NULL;
00098 playData->size = 0;
00099 playData->title = NULL;
00100 playData->msg = NULL;
00101
00102
00103 event = new QCustomEvent( (QEvent::Type)(QEvent::User + 8), playData );
00104
00105 QApplication::postEvent( (QObject*)rio, event );
00106 }
00107 #endif
00108 #endif
00109
00110
00111
00112
00113 char *encryptPassword( const char *pwd )
00114 {
00115 char * pass;
00116
00117 try
00118 {
00119 pass = (char *) malloc( strlen( pwd ) + 1 );
00120
00121 sprintf( pass, "%s" , pwd );
00122 for( unsigned int i = 0; i < strlen( pass ); i++ )
00123 pass[ i ] = ((pass[ i ] & 0x0F) << 4) | ((pass[ i ] & 0xF0) >> 4);
00124
00125 return pass;
00126 }
00127 catch( bad_alloc &ba )
00128 {
00129 return NULL;
00130 }
00131 }
00132
00133 string float2string( float f )
00134 {
00135 ostringstream os;
00136 os << f;
00137
00138 return os.str();
00139 }
00140
00141 string int2string( int i )
00142 {
00143 ostringstream os;
00144 os << i;
00145
00146 return os.str();
00147 }
00148
00149 string short2Permission( short perm )
00150 {
00151 string permission;
00152 const char *p = "rwxrwxrwx";
00153
00154 for( int j = 0x100; *p != '\0'; p++ )
00155 {
00156 if( j & perm )
00157 permission += *p;
00158 else
00159 permission += "-";
00160 j >>= 1;
00161 }
00162
00163 return permission;
00164 }