diff options
Diffstat (limited to 'src')
84 files changed, 1209 insertions, 570 deletions
diff --git a/src/kvilib/CMakeLists.txt b/src/kvilib/CMakeLists.txt index 108bb39ba..9392c6dd0 100644 --- a/src/kvilib/CMakeLists.txt +++ b/src/kvilib/CMakeLists.txt @@ -38,6 +38,7 @@ SET(kvilib_MOC_HDRS tal/kvi_tal_vbox.h tal/kvi_tal_widgetstack.h tal/kvi_tal_wizard.h + ext/kvi_animatedpixmap.h ) IF(COMPILE_KDE_SUPPORT) @@ -80,6 +81,8 @@ SET(kvilib_SRCS ext/kvi_msgtype.cpp ext/kvi_osinfo.cpp ext/kvi_pixmap.cpp + ext/kvi_animatedpixmap.cpp + ext/kvi_animatedpixmapcache.cpp ext/kvi_proxydb.cpp ext/kvi_regchan.cpp ext/kvi_regusersdb.cpp diff --git a/src/kvilib/config/kvi_buildinfo.cpp b/src/kvilib/config/kvi_buildinfo.cpp index 00812c239..404b8bc12 100644 --- a/src/kvilib/config/kvi_buildinfo.cpp +++ b/src/kvilib/config/kvi_buildinfo.cpp @@ -23,8 +23,6 @@ // //============================================================================= -#define __KVILIB__ - #include "kvi_buildinfo.h" #include "kvi_sourcesdate.h" diff --git a/src/kvilib/core/kvi_error.cpp b/src/kvilib/core/kvi_error.cpp index dd4355117..c627d62c6 100644 --- a/src/kvilib/core/kvi_error.cpp +++ b/src/kvilib/core/kvi_error.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #define _KVI_ERROR_CPP_ @@ -48,7 +47,7 @@ const char * g_errorTable[KVI_NUM_ERRORS]= { - __tr_no_lookup("Success"), // 000: success + __tr_no_lookup("Success"), // 000: success __tr_no_lookup("Unknown error"), // 001: unkonwnError __tr_no_lookup("Internal error"), // 002: internalError __tr_no_lookup("Unknown command"), // 003: unknownCommand @@ -182,12 +181,12 @@ namespace KviError #endif return g_errorTable[KviError_unknownError]; } - + QString getDescription(int iErrorCode) { return __tr2qs_no_xgettext(getUntranslatedDescription(iErrorCode)); } - + int translateSystemError(int iErrNo) { #if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) @@ -203,14 +202,14 @@ namespace KviError case WSAENETUNREACH: return KviError_networkUnreachable; break; case EPIPE: return KviError_brokenPipe; break; case WSAENOTCONN: return KviError_socketNotConnected; break; - + case WSAEACCES: return KviError_accessDenied; break; case WSAEADDRINUSE: return KviError_addressAlreadyInUse; break; case WSAEADDRNOTAVAIL: return KviError_cantAssignRequestedAddress; break; case WSAEAFNOSUPPORT: return KviError_unsupportedAddressFamily; break; case WSAECONNRESET: return KviError_connectionResetByPeer; break; case WSAEHOSTUNREACH: return KviError_hostUnreachable; break; - + //case ENOBUFS: return KviError_insufficientResources; break; // Unhandled error...pass errno to the strerror function default: return -iErrNo; break; diff --git a/src/kvilib/core/kvi_heapobject.cpp b/src/kvilib/core/kvi_heapobject.cpp index 92bc2fc6b..8b0a4de7e 100644 --- a/src/kvilib/core/kvi_heapobject.cpp +++ b/src/kvilib/core/kvi_heapobject.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_heapobject.h" @@ -65,7 +64,7 @@ { return kvi_malloc(uSize); } - + void KviHeapObject::operator delete(void * pData) { kvi_free(pData); @@ -75,7 +74,7 @@ { return kvi_malloc(uSize); } - + void KviHeapObject::operator delete[](void * pData) { kvi_free(pData); @@ -86,7 +85,7 @@ { return kvi_malloc(uSize); } - + void KviHeapObject::operator delete(void * pData,const char *,int) { kvi_free(pData); diff --git a/src/kvilib/core/kvi_malloc.cpp b/src/kvilib/core/kvi_malloc.cpp index 18ee5bb4d..63e4b6786 100644 --- a/src/kvilib/core/kvi_malloc.cpp +++ b/src/kvilib/core/kvi_malloc.cpp @@ -28,7 +28,6 @@ // kvi_malloc , kvi_free and kvi_realloc are macros (see kvi_malloc.h) //============================================================================= -#define __KVILIB__ #define _KVI_MALLOC_CPP_ #include "kvi_malloc.h" diff --git a/src/kvilib/core/kvi_memmove.cpp b/src/kvilib/core/kvi_memmove.cpp index 96fe0c50e..2aa6d8815 100644 --- a/src/kvilib/core/kvi_memmove.cpp +++ b/src/kvilib/core/kvi_memmove.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #define _KVI_DEBUG_CHECK_RANGE_ #include "kvi_debug.h" @@ -33,7 +32,7 @@ // FIXME: #warning "With system memmove could be guessed by configure" #ifndef COMPILE_WITH_SYSTEM_MEMMOVE - + #ifdef COMPILE_ix86_ASM @@ -97,7 +96,7 @@ asm(" popl %esi"); // restore %esi return dst_ptr; //asm(" movl 8(%ebp),%eax"); <-- gcc will put that (AFTER THE OPTIMISATION PASS!) } - + void *kvi_memmoveodd(void * dst_ptr,const void *src_ptr,int len) { __range_valid(dst_ptr); @@ -149,14 +148,14 @@ } #else // ndef COMPILE_ix86_ASM - + // The next 4 functions could be optimized with the & and shift technique // used in the assembly implementations but the compilers usually // will not translate the carry bit trick producing code // that works slower on short block of memory (really near the average case) - + // The trick would be: // // if(len & 1) // the length is even @@ -168,7 +167,7 @@ // while(len--)*((int *)dst)-- = *((int *)src)--; // move four bytes at a time // // - + void *kvi_memmove(void *dst_ptr,const void *src_ptr,int len) { __range_valid(dst_ptr); @@ -180,14 +179,14 @@ dst = (char *)dst_ptr + len - 1; src = (const char *)src_ptr + len - 1; while(len--)*dst-- = *src--; - } else { //it is valid even if dst_ptr == src_ptr + } else { //it is valid even if dst_ptr == src_ptr dst = (char *)dst_ptr; src = (const char *)src_ptr; while(len--)*dst++ = *src++; } return dst_ptr; } - + void *kvi_memmoveodd(void *dst_ptr,const void *src_ptr,int len) { __range_valid(dst_ptr); @@ -204,7 +203,7 @@ *dst-- = *src--; len -= 2; } - } else { //it is valid even if dst_ptr == src_ptr + } else { //it is valid even if dst_ptr == src_ptr dst = (short *)dst_ptr; src = (const short *)src_ptr; while(len > 0) @@ -215,7 +214,7 @@ } return dst_ptr; } - + void kvi_fastmove(void *dst_ptr,const void *src_ptr,int len) { __range_valid(dst_ptr); @@ -225,7 +224,7 @@ register char *dst = (char *)dst_ptr; while(len--)*dst++ = *src++; } - + void kvi_fastmoveodd(void *dst_ptr,const void *src_ptr,int len) { __range_valid(dst_ptr); @@ -241,7 +240,7 @@ } #endif // !COMPILE_ix86_ASM - + void kvi_memset(void *dst_ptr,char c,int len) { __range_valid(dst_ptr); diff --git a/src/kvilib/core/kvi_memmove.h b/src/kvilib/core/kvi_memmove.h index e220808d1..359fcb7da 100644 --- a/src/kvilib/core/kvi_memmove.h +++ b/src/kvilib/core/kvi_memmove.h @@ -25,7 +25,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_settings.h" @@ -54,7 +53,7 @@ extern void *kvi_memmoveodd(void *dst_ptr,const void *src_ptr,int len); extern void *kvi_memset(void *dst_ptr,char c,int len); // In fastmove the src and dst may not overlap - + #ifdef COMPILE_ix86_ASM // WE WANT repnz; movsq\n"!!! diff --git a/src/kvilib/core/kvi_qstring.cpp b/src/kvilib/core/kvi_qstring.cpp index bfa5cb63f..b68cfacda 100644 --- a/src/kvilib/core/kvi_qstring.cpp +++ b/src/kvilib/core/kvi_qstring.cpp @@ -28,8 +28,6 @@ // //============================================================================= -#define __KVILIB__ - #include "kvi_qstring.h" #include "kvi_string.h" @@ -59,9 +57,9 @@ namespace KviQString unsigned int lmin = MY_MIN(sz1.length(),sz2.length()); if(lmin < len)return false; const QChar * c1e = c1 + len; - + if(!c1 || !c2)return (c1 == c2); - + while(c1 < c1e) { if(c1->unicode() != c2->unicode())return false; @@ -180,9 +178,9 @@ namespace KviQString const QChar * c1 = sz1.unicode(); const QChar * c2 = sz2.unicode(); const QChar * c1e = c1 + sz1.length(); - + if(!c1 || !c2)return (c1 == c2); - + while(c1 < c1e) { if(c1->unicode() != c2->unicode())return false; @@ -434,14 +432,14 @@ namespace KviQString //sz.resize(sz.length()); // detach! return sz.constData(); } - + void appendNumber(QString &s,double dReal) { char buffer[512]; ::sprintf(buffer,"%f",dReal); s.append(buffer); } - + void appendNumber(QString &s,int iInteger) { char buffer[64]; @@ -455,14 +453,14 @@ namespace KviQString ::sprintf(buffer,"%ld",iInteger); s.append(buffer); } - + void appendNumber(QString &s,kvi_u64_t uInteger) { char buffer[64]; ::sprintf(buffer,"%lu",uInteger); s.append(buffer); } - + void appendNumber(QString &s,unsigned int uInteger) { char buffer[64]; @@ -492,7 +490,7 @@ namespace KviQString char *argString; long argValue; unsigned long argUValue; - + //9999999999999999999999999999999\0 char numberBuffer[32]; //enough ? 10 is enough for 32bit unsigned int... char *pNumBuf; @@ -716,17 +714,17 @@ namespace KviQString bool matchWildExpressionsCI(const QString &szM1,const QString &szM2) { //Matches two regular expressions containging wildcards (* and ?) - + // s1 // m1 // mask1 : *xor // mask2 : xorand*xor // m2 // s2 - + // s2 // m2 - // | + // | // XorT!xor@111.111.111.11 // // *!*@*.net @@ -869,7 +867,7 @@ namespace KviQString if(idx == -1)return; s.truncate(bIncluded ? idx : idx + 1); } - + void cutToFirst(QString &s,const QChar &c,bool bIncluded,bool bClearIfNotFound) { int idx = s.indexOf(c); @@ -880,7 +878,7 @@ namespace KviQString } s.remove(0,bIncluded ? idx + 1 : idx); } - + void cutToLast(QString &s,const QChar &c,bool bIncluded,bool bClearIfNotFound) { int idx = s.lastIndexOf(c); @@ -905,7 +903,7 @@ namespace KviQString if(idx == -1)return; s.truncate(bIncluded ? idx : idx + c.length()); } - + void cutToFirst(QString &s,const QString &c,bool bIncluded,bool bClearIfNotFound) { int idx = s.indexOf(c); @@ -916,7 +914,7 @@ namespace KviQString } s.remove(0,bIncluded ? idx + c.length() : idx); } - + void cutToLast(QString &s,const QString &c,bool bIncluded,bool bClearIfNotFound) { int idx = s.lastIndexOf(c); @@ -953,7 +951,7 @@ namespace KviQString kvi_free(buffer); return ret; } - + QString lowerISO88591(const QString &szSrc) { const QChar * c = nullTerminatedArray(szSrc); @@ -997,9 +995,9 @@ namespace KviQString i++; } } - + static char hexdigits[16] = { '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f' }; - + void bufferToHex(QString &szRetBuffer,const unsigned char * buffer,unsigned int len) { szRetBuffer.resize(len * 2); diff --git a/src/kvilib/core/kvi_string.cpp b/src/kvilib/core/kvi_string.cpp index e664401be..966b6baed 100644 --- a/src/kvilib/core/kvi_string.cpp +++ b/src/kvilib/core/kvi_string.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #define _KVI_DEBUG_CHECK_RANGE_ @@ -407,7 +406,7 @@ bool kvi_matchWildExpr(register const char *m1,register const char *m2) // s2 // m2 - // | + // | // XorT!xor@111.111.111.11 // // *!*@*.net @@ -1012,7 +1011,7 @@ int kvi_strMatchRevCS(const char *str1, const char *str2, int index) s1--; s2--; } -} +} KviStr::KviStr() { @@ -1988,53 +1987,53 @@ KviStr & KviStr::hexEncodeWhiteSpace() { static unsigned char ascii_jump_table[256]= { - // 000 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 + // 000 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 // NUL SOH STX ETX EOT ENQ ACK BEL BS HT LF VT FF CR SO SI 1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 , - // 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 + // 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 // DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US 1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 , - // 032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047 - // ! " # $ % & ' ( ) * + , - . / + // 032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047 + // ! " # $ % & ' ( ) * + , - . / 1 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , - // 048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063 - // 0 1 2 3 4 5 6 7 8 9 : ; < = > ? + // 048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063 + // 0 1 2 3 4 5 6 7 8 9 : ; < = > ? 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , - // 064 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079 - // @ A B C D E F G H I J K L M N O + // 064 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079 + // @ A B C D E F G H I J K L M N O 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , - // 080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 095 - // P Q R S T U V W X Y Z [ \ ] ^ _ + // 080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 095 + // P Q R S T U V W X Y Z [ \ ] ^ _ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , - // 096 097 098 099 100 101 102 103 104 105 106 107 108 109 110 111 - // ` a b c d e f g h i j k l m n o + // 096 097 098 099 100 101 102 103 104 105 106 107 108 109 110 111 + // ` a b c d e f g h i j k l m n o 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , - // 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 - // p q r s t u v w x y z { | } ~ + // 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 + // p q r s t u v w x y z { | } ~ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , - // 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 - // + // 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 + // 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , - // 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 - // + // 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 + // 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , - // 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 - // + // 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 + // 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , - // 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 - // + // 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 + // 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , - // 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 - // � � � � � � � � � � � � � � � � + // 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 + // � � � � � � � � � � � � � � � � 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , - // 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 - // � � � � � � � � � � � � � � � � + // 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 + // � � � � � � � � � � � � � � � � 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , - // 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 - // � � � � � � � � � � � � � � � � + // 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 + // � � � � � � � � � � � � � � � � 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , - // 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 - // � � � � � � � � + // 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 + // � � � � � � � � 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 }; @@ -2418,7 +2417,7 @@ long KviStr::toLongExt(bool *bOk,int base) // if(*endptr != '\0'){ // if(bOk)*bOk = false; // } -// return result; +// return result; //} KviStr & KviStr::cutLeft(int len) @@ -2731,7 +2730,7 @@ int KviStr::findFirstIdx(const char *str,bool caseS) const // We must throw away KviStr at all in this case... // return QString(m_ptr).find(QString(str),0,caseS);; - + // Both this KviStr and the const char * str are assumed // to be in the proper (and same) encoding. // If KviStr is in encoding A then QString(m_ptr) might @@ -2841,7 +2840,7 @@ KviStr & KviStr::trimmed() // 0123456789 // abcd 0 // ^ ^ - // left right + // left right m_len = (right - left)+1; kvi_memmove(m_ptr,left,m_len); m_ptr = (char *)kvi_realloc(m_ptr,m_len+1); @@ -2860,7 +2859,8 @@ KviStr & KviStr::stripRightWhiteSpace() { register char *right=m_ptr+m_len-1; const char *start=right; - while((right >= m_ptr) && isspace( *right ))right--; + //isspace accepts 0..255 values in MSVC + while((right >= m_ptr) && ((unsigned)(*right +1) <= 256) && isspace( *right ))right--; if(right != start) { m_len = (right - m_ptr) + 1; @@ -2904,7 +2904,7 @@ KviStr & KviStr::stripSpace() // 0123456789 // abcd 0 // ^ ^ - // left right + // left right m_len = (right - left)+1; kvi_memmove(m_ptr,left,m_len); m_ptr = (char *)kvi_realloc(m_ptr,m_len+1); @@ -3010,52 +3010,52 @@ bool KviStr::ext_contains(register const char * data,const char * item,bool case // static char ascii_jump_table[256]= // { -// // 000 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 +// // 000 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 // // NUL SOH STX ETX EOT ENQ ACK BEL BS HT LF VT FF CR SO SI // 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -// // 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 +// // 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 // // DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US // 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -// // 032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047 -// // ! " # $ % & ' ( ) * + , - . / +// // 032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047 +// // ! " # $ % & ' ( ) * + , - . / // 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -// // 048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063 -// // 0 1 2 3 4 5 6 7 8 9 : ; < = > ? +// // 048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063 +// // 0 1 2 3 4 5 6 7 8 9 : ; < = > ? // 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -// // 064 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079 -// // @ A B C D E F G H I J K L M N O +// // 064 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079 +// // @ A B C D E F G H I J K L M N O // 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -// // 080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 095 -// // P Q R S T U V W X Y Z [ \ ] ^ _ +// // 080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 095 +// // P Q R S T U V W X Y Z [ \ ] ^ _ // 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -// // 096 097 098 099 100 101 102 103 104 105 106 107 108 109 110 111 -// // ` a b c d e f g h i j k l m n o +// // 096 097 098 099 100 101 102 103 104 105 106 107 108 109 110 111 +// // ` a b c d e f g h i j k l m n o // 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -// // 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 -// // p q r s t u v w x y z { | } ~ +// // 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 +// // p q r s t u v w x y z { | } ~ // 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -// // 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 -// // +// // 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 +// // // 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -// // 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 -// // +// // 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 +// // // 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -// // 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 -// // +// // 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 +// // // 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -// // 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 -// // +// // 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 +// // // 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -// // 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 -// // � � � � � � � � � � � � � � � � +// // 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 +// // � � � � � � � � � � � � � � � � // 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -// // 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 -// // � � � � � � � � � � � � � � � � +// // 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 +// // � � � � � � � � � � � � � � � � // 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -// // 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 -// // � � � � � � � � � � � � � � � � +// // 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 +// // � � � � � � � � � � � � � � � � // 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -// // 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 -// // � � � � � � � � +// // 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 +// // � � � � � � � � // 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 // }; diff --git a/src/kvilib/core/kvi_stringarray.cpp b/src/kvilib/core/kvi_stringarray.cpp index 9799c57ed..6e9169f15 100644 --- a/src/kvilib/core/kvi_stringarray.cpp +++ b/src/kvilib/core/kvi_stringarray.cpp @@ -22,7 +22,6 @@ // //================================================================================================= -#define __KVILIB__ #include "kvi_stringarray.h" diff --git a/src/kvilib/ext/kvi_animatedpixmap.cpp b/src/kvilib/ext/kvi_animatedpixmap.cpp new file mode 100644 index 000000000..33c079bce --- /dev/null +++ b/src/kvilib/ext/kvi_animatedpixmap.cpp @@ -0,0 +1,86 @@ +/* + * kvi_animatedpixmap.cpp + * + * Created on: 30.07.2008 + * Author: Alexey + */ + +#include "kvi_animatedpixmap.h" +#include "kvi_settings.h" +#include <QImageReader> +#include <QHash> +#include <QMutexLocker> + +KviAnimatedPixmap::KviAnimatedPixmap(QString fileName) + :m_szFileName(fileName) +{ + m_bStarted = 0; + m_uCurrentFrameNumber = 0; + + connect(&m_timer,SIGNAL(timeout()),this,SLOT(animationTimerShot())); + + m_lFrames=KviAnimatedPixmapCache::load(fileName); + start(); +} + +KviAnimatedPixmap::KviAnimatedPixmap(KviAnimatedPixmap* source) + :m_szFileName(source->m_szFileName), + m_uCurrentFrameNumber(source->m_uCurrentFrameNumber), + m_bStarted(source->m_bStarted), //keep started state + m_lFrames(source->m_lFrames) +{ + m_lFrames->refs++; + connect(&m_timer,SIGNAL(timeout()),this,SLOT(animationTimerShot())); + + //restore started state + if(isStarted() && (framesCount()>1)) + { + m_timer.start(m_lFrames->at(m_uCurrentFrameNumber).delay); + } +} + +KviAnimatedPixmap::~KviAnimatedPixmap() +{ + // all pixmaps will be automagically deleted at + // FrameInfo::~FrameInfo destructor:)) + + KviAnimatedPixmapCache::free(m_lFrames); +} + +void KviAnimatedPixmap::start() +{ + if(!isStarted() && (framesCount()>1)) + { + m_timer.start(m_lFrames->at(m_uCurrentFrameNumber).delay); + m_bStarted = true; + } +} + +void KviAnimatedPixmap::stop() +{ + if(isStarted()) + { + m_timer.stop(); + m_bStarted = false; + } +} + +void KviAnimatedPixmap::animationTimerShot() +{ + m_uCurrentFrameNumber++; + //Ensure, that we are not out of bounds + m_uCurrentFrameNumber %= m_lFrames->count(); + + emit(frameChanged()); + + //run timer again + m_timer.start(m_lFrames->at(m_uCurrentFrameNumber).delay); +} + +void KviAnimatedPixmap::resize(QSize newSize,Qt::AspectRatioMode ratioMode) +{ + QSize curSize(size()); + curSize.scale(newSize,ratioMode); + + m_lFrames = KviAnimatedPixmapCache::resize(m_lFrames,curSize); +} diff --git a/src/kvilib/ext/kvi_animatedpixmap.h b/src/kvilib/ext/kvi_animatedpixmap.h new file mode 100644 index 000000000..5a54f9dc5 --- /dev/null +++ b/src/kvilib/ext/kvi_animatedpixmap.h @@ -0,0 +1,158 @@ +/* + * kvi_animatedpixmap.h + * + * Created on: 30.07.2008 + * Author: Alexey + */ + +#ifndef KVI_ANIMATEDPIXMAP_H_ +#define KVI_ANIMATEDPIXMAP_H_ + +#include <QObject> +#include <QPixmap> +#include <QList> +#include <QTimer> +#include "kvi_settings.h" +#include "kvi_animatedpixmapcache.h" + +/** + * This class should not be here, because we already have QMovie + * with the same functionality. + * + * But QMovie is really stupid, bacause: + * 1) It does not support infinitive animation. + * It relies on image metadata to determine loop count. So most of pics will + * be played only once. + * + * 2) It dublicates QPixmap while we calls currentFrame(), that's a very + * big overload for us. + * + * 3) If we try to scale QMovie by using built-in scale mechanism, it will + * manually scale each frame each time, we will call currentFrame(). + * So if we plan to play movie 10,100,1000 times, it will scale image + * 10,100,1000 times too:( + * + * 4) KviAnimatedPixmap uses internal cache mechanism with KviAnimatedPixmapCache class. + * It's managed inside KviAnimatedPixmap and KviAnimatedPixmapCache. No othet actions + * needed to perform caching. + * + * So... Here is my workaround. It's working in this way: + * You should create new pixmap with constructor KviAnimatedPixmap(QString fileName). + * It will automagically look at cache and use it, if possible. + * + * KviAnimatedPixmap stores animation as a set of QPixmap's, and delays. + * when started (see start()) it emits frameChanged() events at the frame change. + * + * You should use pixmap() methd to access the current frame. + * + * This class owns all pixmaps. Do not store links to them. + */ + +class KVILIB_API KviAnimatedPixmap : public QObject{ + Q_OBJECT + +protected: + QString m_szFileName; + KviAnimatedPixmapCache::Data* m_lFrames; + QTimer m_timer; + + uint m_uCurrentFrameNumber; + bool m_bStarted; +public: + /* + * Creates KviAnimatedPixmap, and loads data from "fileName". + */ + KviAnimatedPixmap(QString fileName); + + virtual ~KviAnimatedPixmap(); + + /* + * Creates new pixmap using "source" as source of images. + */ + KviAnimatedPixmap(KviAnimatedPixmap* source); + + /* + * Returns true if animation is started. + * Returns false otherways. + */ + inline bool isStarted() + { + return m_bStarted; + } + + /* + * Starts the animation + */ + void start(); + + /* + * Stops the animation + */ + void stop(); + + /* + * Returns true if animation has at least one loaded frame. + * Returns false otherways. + */ + inline bool isValid() + { + return (m_lFrames->count()>0); + } + + /* + * Returns active frame's pixmap + */ + inline QPixmap* pixmap() + { + if(m_lFrames->count()>0) + return m_lFrames->at(m_uCurrentFrameNumber).pixmap; + else + return 0; + } + + /* + * Returns active frame number + */ + inline uint activeFrameNumber() + { + return m_uCurrentFrameNumber; + } + + /* + * Returns animation frame count + */ + inline uint framesCount() + { + return m_lFrames->count(); + } + + /* + * Returns current image size + */ + inline const QSize& size() + { + return m_lFrames->size; + } + + /* + * Resizes all frames to the newSize size, using "ratioMode" + * ratio. + */ + void resize(QSize newSize,Qt::AspectRatioMode ratioMode); + +protected slots: + + /* + * Slot, to be connected to m_animationTimer, to receive animation + * frame changes. + */ + void animationTimerShot(); + +signals: + /* + * This signal emitted when active frame changes + */ + void frameChanged(); +}; + +#endif /* KVI_ANIMATEDPIXMAP_H_ */ diff --git a/src/kvilib/ext/kvi_animatedpixmapcache.cpp b/src/kvilib/ext/kvi_animatedpixmapcache.cpp new file mode 100644 index 000000000..4e997ad39 --- /dev/null +++ b/src/kvilib/ext/kvi_animatedpixmapcache.cpp @@ -0,0 +1,137 @@ +/* + * kvi_animatedpixmapcache.cpp + * + * Created on: 31.07.2008 + * Author: Alexey + */ + +#include <kvi_animatedpixmapcache.h> +#include <QImageReader> +#include <QImage> + +static KviAnimatedPixmapCache* g_pAnimatedCache = 0; + +KviAnimatedPixmapCache::KviAnimatedPixmapCache() { + g_pAnimatedCache = this; +} + +KviAnimatedPixmapCache::~KviAnimatedPixmapCache() { + // TODO Auto-generated destructor stub +} + +KviAnimatedPixmapCache::Data* KviAnimatedPixmapCache::internalLoad(QString szFile) { + m_cacheMutex.lock(); + + Data* newData = 0; + + QMultiHash<QString, Data*>::iterator i = m_hCache.find(szFile); + while (i != m_hCache.end() && i.key() == szFile && !newData) { + if (!i.value()->resized) { + newData = i.value(); + } + ++i; + } + + if (!newData) { + newData = new Data(szFile); + QImageReader reader(szFile); + newData->size = reader.size(); + + QImage buffer; + QPixmap* framePixmap; + while(reader.canRead()) + { + uint delay = reader.nextImageDelay(); + reader.read(&buffer); + if(!buffer.isNull()) + { + framePixmap = new QPixmap(QPixmap::fromImage(buffer)); + newData->append(FrameInfo(framePixmap,delay)); + } + } + m_hCache.insert(szFile,newData); + } + newData->refs++; + + m_cacheMutex.unlock(); + + return newData; +} +KviAnimatedPixmapCache::Data* KviAnimatedPixmapCache::internalResize(Data* data, QSize size) { + m_cacheMutex.lock(); + + bool hasToBeResized = false; + + Data* newData = 0; + QMultiHash<QString, Data*>::iterator i = m_hCache.find(data->file); + while (i != m_hCache.end() && i.key() == data->file && !newData) { + if (i.value()->size == size) { + newData = i.value(); + } + ++i; + } + + if(!newData) + { + newData = new Data(*data); + newData->size = size; + m_hCache.insert(newData->file,newData); + hasToBeResized = true; + newData->resized = true; + } + + newData->refs++; + + m_cacheMutex.unlock(); + + internalFree(data); + + if(hasToBeResized) + { + for(int i=0;i<newData->count();i++) { + QPixmap* old = newData->at(i).pixmap; + newData->operator [](i).pixmap=new QPixmap(old->scaled(size,Qt::IgnoreAspectRatio,Qt::SmoothTransformation)); + delete old; + } + } + + return newData; +} + +void KviAnimatedPixmapCache::internalFree(Data* data) { + m_cacheMutex.lock(); + data->refs--; + if(data->refs==0) + { + m_hCache.remove(data->file,data); + for(int i=0;i<data->count();i++) + { + delete data->operator [](i).pixmap; + } + delete data; + } + m_cacheMutex.unlock(); +} + +KviAnimatedPixmapCache::Data* KviAnimatedPixmapCache::load(QString szFileName) { + if (!g_pAnimatedCache) { + new KviAnimatedPixmapCache(); + } + return g_pAnimatedCache->internalLoad(szFileName); +} + + +KviAnimatedPixmapCache::Data* KviAnimatedPixmapCache::resize(KviAnimatedPixmapCache::Data* data, QSize size) { + if (!g_pAnimatedCache) { + new KviAnimatedPixmapCache(); + } + return g_pAnimatedCache->internalResize(data, size); +} + + +void KviAnimatedPixmapCache::free(KviAnimatedPixmapCache::Data* data) { + if (!g_pAnimatedCache) { + new KviAnimatedPixmapCache(); + } + g_pAnimatedCache->internalFree(data); +} diff --git a/src/kvilib/ext/kvi_animatedpixmapcache.h b/src/kvilib/ext/kvi_animatedpixmapcache.h new file mode 100644 index 000000000..9fe558688 --- /dev/null +++ b/src/kvilib/ext/kvi_animatedpixmapcache.h @@ -0,0 +1,96 @@ +/* + * kvi_animatedpixmapcache.h + * + * Created on: 31.07.2008 + * Author: Alexey + */ + +#ifndef KVI_ANIMATEDPIXMAPCACHE_H_ +#define KVI_ANIMATEDPIXMAPCACHE_H_ + +#include <QMutex> +#include <QPixmap> +#include <QMultiHash> + +class KviAnimatedPixmapCache { + +public: + /* + * This subclass represents simple structure + * to store animated frame data: cached pixmap, and next frame delay. + * + * It provides copyconstructor, wich makes possible to simple + * assign two containers with this classes. + * + * All data will be dublicated in such case. + */ + class FrameInfo { + public: + QPixmap *pixmap; //frame pixmap + uint delay; //next frame delay + + FrameInfo(QPixmap *_pixmap, uint _delay) { + pixmap = _pixmap; + delay = _delay; + } + + FrameInfo(const FrameInfo& source) { + pixmap = source.pixmap; + delay = source.delay; + } + + void detach() { + pixmap = new QPixmap(*pixmap); + } + }; + + /* + * This helper class represents data structure + * for storing frames. + * + * It adds references counter and + * mutex, to provide thread-safety. + */ + class Data: public QList<FrameInfo> { + public: + uint refs; //references count + QSize size; //size of the pixmaps + QString file; //just to speedup the cache + bool resized; + + Data(QString szFile) : + QList<FrameInfo> (), refs(0), resized(false), file(szFile) { + } + + Data(Data& other) : + QList<FrameInfo> (other), refs(0), resized(false), file(other.file) { + for(int i=0;i<count();i++) + { + this->operator [](i).detach(); + } + } + }; +protected: + + mutable QMutex m_cacheMutex; + QMultiHash<QString,Data*> m_hCache; + + /* + * This class is a singletone. + * It doesn't allow to be created directly; + */ + KviAnimatedPixmapCache(); + + Data* internalLoad (QString szFile); + Data* internalResize(Data* data,QSize size); + + void internalFree(Data* data); +public: + virtual ~KviAnimatedPixmapCache(); + + static Data* load(QString szFileName); + static Data* resize(Data* data,QSize size); + static void free(Data* data); +}; + +#endif /* KVI_ANIMATEDPIXMAPCACHE_H_ */ diff --git a/src/kvilib/ext/kvi_cmdformatter.cpp b/src/kvilib/ext/kvi_cmdformatter.cpp index 23c0fcc2b..6ca33e04c 100644 --- a/src/kvilib/ext/kvi_cmdformatter.cpp +++ b/src/kvilib/ext/kvi_cmdformatter.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_cmdformatter.h" diff --git a/src/kvilib/ext/kvi_config.cpp b/src/kvilib/ext/kvi_config.cpp index e355c58f0..bfcfe1f78 100644 --- a/src/kvilib/ext/kvi_config.cpp +++ b/src/kvilib/ext/kvi_config.cpp @@ -22,7 +22,6 @@ // //========================================================================================== -#define __KVILIB__ #include "kvi_config.h" #include "kvi_fileutils.h" @@ -210,7 +209,7 @@ bool KviConfig::load() p = buffer; // start from beginning of the data buffer at all // begin of the current string char * begin = p; - + // and loop while(p < endp) { @@ -225,7 +224,7 @@ bool KviConfig::load() // now begin points to the string that terminates in p // skip leading whitespace while((*begin == '\t') || (*begin == ' '))begin++; - + if(p == begin) { // empty line @@ -304,7 +303,7 @@ bool KviConfig::load() tmp.stripRightWhiteSpace(); // No external spaces at all in keys if(!tmp.isEmpty()) { - QString szKey = m_bLocal8Bit ? + QString szKey = m_bLocal8Bit ? QString::fromLocal8Bit(tmp.ptr(),tmp.len()) : QString::fromUtf8(tmp.ptr(),tmp.len()); z++; @@ -312,7 +311,7 @@ bool KviConfig::load() if(*z) { tmp.hexDecode(z); - QString * pVal = new QString( m_bLocal8Bit ? + QString * pVal = new QString( m_bLocal8Bit ? QString::fromLocal8Bit(tmp.ptr(),tmp.len()) : QString::fromUtf8(tmp.ptr(),tmp.len()) ); @@ -391,7 +390,7 @@ bool KviConfig::load() { QString szUtf8 = QString::fromUtf8(dataLine.ptr()); p_group = m_pDict->find(szUtf8); - + if(!p_group) { p_group = new KviConfigGroup(17,false); @@ -440,53 +439,53 @@ bool KviConfig::save() { static unsigned char encode_table[256]= { - // 000 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 + // 000 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 // NUL SOH STX ETX EOT ENQ ACK BEL BS HT LF VT FF CR SO SI 1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 , - // 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 + // 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 // DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US 1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 , - // 032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047 - // ! " # $ % & ' ( ) * + , - . / + // 032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047 + // ! " # $ % & ' ( ) * + , - . / 1 ,0 ,0 ,1 ,0 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , - // 048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063 - // 0 1 2 3 4 5 6 7 8 9 : ; < = > ? + // 048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063 + // 0 1 2 3 4 5 6 7 8 9 : ; < = > ? 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,1 ,0 ,0 , - // 064 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079 - // @ A B C D E F G H I J K L M N O + // 064 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079 + // @ A B C D E F G H I J K L M N O 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , - // 080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 095 - // P Q R S T U V W X Y Z [ \ ] ^ _ + // 080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 095 + // P Q R S T U V W X Y Z [ \ ] ^ _ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,1 ,0 ,1 ,0 ,0 , - // 096 097 098 099 100 101 102 103 104 105 106 107 108 109 110 111 - // ` a b c d e f g h i j k l m n o + // 096 097 098 099 100 101 102 103 104 105 106 107 108 109 110 111 + // ` a b c d e f g h i j k l m n o 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , - // 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 - // p q r s t u v w x y z { | } ~ + // 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 + // p q r s t u v w x y z { | } ~ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , - // 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 - // + // 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 + // 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , - // 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 - // + // 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 + // 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , - // 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 - // + // 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 + // 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , - // 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 - // + // 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 + // 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , - // 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 - // � � � � � � � � � � � � � � � � + // 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 + // � � � � � � � � � � � � � � � � 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , - // 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 - // � � � � � � � � � � � � � � � � + // 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 + // � � � � � � � � � � � � � � � � 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , - // 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 - // � � � � � � � � � � � � � � � � + // 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 + // � � � � � � � � � � � � � � � � 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , - // 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 - // � � � � � � � � + // 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 + // � � � � � � � � 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 }; @@ -519,7 +518,7 @@ bool KviConfig::save() szValue = m_bLocal8Bit ? KviQString::toLocal8Bit(*p_str) : KviQString::toUtf8(*p_str); szName.hexEncodeWithTable(encode_table); szValue.hexEncodeWhiteSpace(); - + if(f.writeBlock(szName.ptr(),szName.len()) < (int) szName.len())return false; if(!f.putChar('='))return false; if(f.writeBlock(szValue.ptr(),szValue.len()) < (int) szValue.len())return false; diff --git a/src/kvilib/ext/kvi_crypt.cpp b/src/kvilib/ext/kvi_crypt.cpp index 3dd689daa..cffdf9b69 100644 --- a/src/kvilib/ext/kvi_crypt.cpp +++ b/src/kvilib/ext/kvi_crypt.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_crypt.h" #include "kvi_locale.h" @@ -212,7 +211,7 @@ { KviPointerList<QString> lEnginesToRemove; lEnginesToRemove.setAutoDelete(true); - + for(KviPointerHashTableEntry<QString,KviCryptEngineDescription> * e = m_pEngineDict->firstEntry();e;e = m_pEngineDict->nextEntry()) { if(e->data()->providerHandle == providerHandle) diff --git a/src/kvilib/ext/kvi_databuffer.cpp b/src/kvilib/ext/kvi_databuffer.cpp index 0f6920279..9dce77807 100644 --- a/src/kvilib/ext/kvi_databuffer.cpp +++ b/src/kvilib/ext/kvi_databuffer.cpp @@ -20,7 +20,6 @@ // Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // -#define __KVILIB__ #define _KVI_DEBUG_CHECK_RANGE_ diff --git a/src/kvilib/ext/kvi_dcophelper.cpp b/src/kvilib/ext/kvi_dcophelper.cpp index 8b7217ba3..fd3b8e1e5 100644 --- a/src/kvilib/ext/kvi_dcophelper.cpp +++ b/src/kvilib/ext/kvi_dcophelper.cpp @@ -23,7 +23,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_dcophelper.h" #ifdef COMPILE_KDE3_SUPPORT diff --git a/src/kvilib/ext/kvi_doublebuffer.cpp b/src/kvilib/ext/kvi_doublebuffer.cpp index 66acefeb8..477a580f6 100644 --- a/src/kvilib/ext/kvi_doublebuffer.cpp +++ b/src/kvilib/ext/kvi_doublebuffer.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_doublebuffer.h" diff --git a/src/kvilib/ext/kvi_garbage.cpp b/src/kvilib/ext/kvi_garbage.cpp index 072e2ec3e..de7600075 100644 --- a/src/kvilib/ext/kvi_garbage.cpp +++ b/src/kvilib/ext/kvi_garbage.cpp @@ -19,7 +19,6 @@ // along with this program. If not, write to the Free Software Foundation, // Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // -#define __KVILIB__ diff --git a/src/kvilib/ext/kvi_md5.cpp b/src/kvilib/ext/kvi_md5.cpp index 5e22fb2d0..e3916c5b1 100644 --- a/src/kvilib/ext/kvi_md5.cpp +++ b/src/kvilib/ext/kvi_md5.cpp @@ -20,43 +20,42 @@ // Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // -#define __KVILIB__ /* ###################################################################### - + MD5Sum - MD5 Message Digest Algorithm. - This code implements the MD5 message-digest algorithm. The algorithm is - due to Ron Rivest. This code was written by Colin Plumb in 1993, no - copyright is claimed. This code is in the public domain; do with it what + This code implements the MD5 message-digest algorithm. The algorithm is + due to Ron Rivest. This code was written by Colin Plumb in 1993, no + copyright is claimed. This code is in the public domain; do with it what you wish. - - Equivalent code is available from RSA Data Security, Inc. This code has - been tested against that, and is equivalent, except that you don't need to + + Equivalent code is available from RSA Data Security, Inc. This code has + been tested against that, and is equivalent, except that you don't need to include two pages of legalese with every copy. To compute the message digest of a chunk of bytes, instantiate the class, - and repeatedly call one of the Add() members. When finished the Result + and repeatedly call one of the Add() members. When finished the Result method will return the Hash and finalize the value. - + Changed so as no longer to depend on Colin Plumb's `usual.h' header definitions; now uses stuff from dpkg's config.h. - Ian Jackson <ijackson@nyx.cs.du.edu>. - + Changed into a C++ interface and made work with APT's config.h. - Jason Gunthorpe <jgg@gpu.srv.ualberta.ca> Interface adapted to the KVIrc irc client - Szymon Stefanek <pragma at kvirc dot net> - + The classes use arrays of char that are a specific size. We cast those arrays to uint8_t's and go from there. This allows us to advoid using the uncommon inttypes.h in a public header or internally newing memory. In theory if C9x becomes nicely accepted - + ##################################################################### */ #include "kvi_md5.h" @@ -69,7 +68,7 @@ static void byteSwap(kvi_u32_t *buf,unsigned int words) { // kvi_u8_t *p = (kvi_u8_t *)buf; -// do +// do // { // *buf++ = (kvi_u32_t)((unsigned)p[3] << 8 | p[2]) << 16 | ((unsigned)p[1] << 8 | p[0]); // p += 4; @@ -212,11 +211,11 @@ bool KviMd5::add(const unsigned char *data,unsigned long len) // Update byte count and carry (this could be done with a long long?) kvi_u32_t t = bytes[0]; - if ((bytes[0] = t + len) < t)bytes[1]++; + if ((bytes[0] = t + len) < t)bytes[1]++; // Space available (at least 1) - t = 64 - (t & 0x3f); - if (t > len) + t = 64 - (t & 0x3f); + if (t > len) { kvi_fastmove((unsigned char *)in + 64 - t,data,len); return true; @@ -260,7 +259,7 @@ KviStr KviMd5::result() if(!m_bDone) { // Number of bytes in In - int count = bytes[0] & 0x3f; + int count = bytes[0] & 0x3f; unsigned char *p = (unsigned char *)in + count; // Set the first char of padding to 0x80. There is always room. @@ -269,8 +268,8 @@ KviStr KviMd5::result() // Bytes of padding needed to make 56 bytes (-8..55) count = 56 - 1 - count; - // Padding forces an extra block - if (count < 0) + // Padding forces an extra block + if (count < 0) { kvi_memset(p,0,count + 8); byteSwap(in, 16); diff --git a/src/kvilib/ext/kvi_mediatype.cpp b/src/kvilib/ext/kvi_mediatype.cpp index 1fafd09a5..b35686234 100644 --- a/src/kvilib/ext/kvi_mediatype.cpp +++ b/src/kvilib/ext/kvi_mediatype.cpp @@ -20,7 +20,6 @@ // Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // -#define __KVILIB__ //#define _KVI_DEBUG_CHECK_RANGE_ diff --git a/src/kvilib/ext/kvi_miscutils.cpp b/src/kvilib/ext/kvi_miscutils.cpp index 0e1c73d41..b0801e638 100644 --- a/src/kvilib/ext/kvi_miscutils.cpp +++ b/src/kvilib/ext/kvi_miscutils.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_miscutils.h" #include <QStringList> @@ -33,7 +32,7 @@ namespace KviMiscUtils { QStringList sl1 = szVersion1.split("."); QStringList sl2 = szVersion2.split("."); - + QStringList::Iterator it1 = sl1.begin(); QStringList::Iterator it2 = sl2.begin(); while((it1 != sl1.end()) && (it2 != sl2.end())) diff --git a/src/kvilib/ext/kvi_msgtype.cpp b/src/kvilib/ext/kvi_msgtype.cpp index 2ccd6db3c..05caabe4d 100644 --- a/src/kvilib/ext/kvi_msgtype.cpp +++ b/src/kvilib/ext/kvi_msgtype.cpp @@ -20,7 +20,6 @@ // Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // -#define __KVILIB__ #define _KVI_DEBUG_CHECK_RANGE_ diff --git a/src/kvilib/ext/kvi_osinfo.cpp b/src/kvilib/ext/kvi_osinfo.cpp index 9fce81453..af1cd2839 100644 --- a/src/kvilib/ext/kvi_osinfo.cpp +++ b/src/kvilib/ext/kvi_osinfo.cpp @@ -22,7 +22,6 @@ //
///////////////////////////////////////////////////////////////////////////////
-#define __KVILIB__
#include "kvi_osinfo.h"
#include "kvi_locale.h"
@@ -37,12 +36,13 @@ #if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)
#include <windows.h>
-typedef enum QueryInfo
+typedef enum _QueryInfo
{
Os_Release,
Os_Version,
Os_Type
-};
+} QueryInfo;
+
typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
typedef BOOL (WINAPI *PGETPRODUCTINFO)(DWORD,DWORD,DWORD,DWORD,PDWORD);
@@ -97,14 +97,14 @@ static QString queryWinInfo(QueryInfo info) if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) )
{
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
- if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) )
+ if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) )
return FALSE;
}
// Call GetNativeSystemInfo if supported or GetSystemInfo otherwise.
pGNSI = (PGNSI) GetProcAddress(
- GetModuleHandle(TEXT("kernel32.dll")),
+ GetModuleHandle(TEXT("kernel32.dll")),
"GetNativeSystemInfo");
if(NULL != pGNSI)
pGNSI(&si);
@@ -257,7 +257,7 @@ static QString queryWinInfo(QueryInfo info) }
// Test for the server type.
- else if ( osvi.wProductType == VER_NT_SERVER ||
+ else if ( osvi.wProductType == VER_NT_SERVER ||
osvi.wProductType == VER_NT_DOMAIN_CONTROLLER )
{
if(osvi.dwMajorVersion==5 && osvi.dwMinorVersion==2)
@@ -298,7 +298,7 @@ static QString queryWinInfo(QueryInfo info) szVersion+= "Advanced Server " ;
else szVersion+= "Server " ;
}
- else // Windows NT 4.0
+ else // Windows NT 4.0
{
if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
szVersion+="Server 4.0, Enterprise Edition " ;
@@ -308,7 +308,7 @@ static QString queryWinInfo(QueryInfo info) }
}
// Test for specific product on Windows NT 4.0 SP5 and earlier
- else
+ else
{
HKEY hKey;
TCHAR szProductType[BUFSIZE];
@@ -339,9 +339,9 @@ static QString queryWinInfo(QueryInfo info) // Display service pack (if any) and build number.
- if( osvi.dwMajorVersion == 4 &&
+ if( osvi.dwMajorVersion == 4 &&
lstrcmpi( osvi.szCSDVersion, TEXT("Service Pack 6") ) == 0 )
- {
+ {
HKEY hKey;
LONG lRet;
@@ -350,7 +350,7 @@ static QString queryWinInfo(QueryInfo info) TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix\\Q246009"),
0, KEY_QUERY_VALUE, &hKey );
if( lRet == ERROR_SUCCESS )
- szVersion+= QString("Service Pack 6a (Build %1)").arg( osvi.dwBuildNumber & 0xFFFF );
+ szVersion+= QString("Service Pack 6a (Build %1)").arg( osvi.dwBuildNumber & 0xFFFF );
else // Windows NT 4.0 prior to SP6a
{
szVersion+= QString( "%1 (Build %2)").arg( osvi.szCSDVersion).arg( osvi.dwBuildNumber & 0xFFFF);
@@ -358,7 +358,7 @@ static QString queryWinInfo(QueryInfo info) RegCloseKey( hKey );
}
- else // not Windows NT 4.0
+ else // not Windows NT 4.0
{
szVersion+= QString( "%1 (Build %2)").arg( osvi.szCSDVersion).arg( osvi.dwBuildNumber & 0xFFFF);
}
@@ -373,19 +373,19 @@ static QString queryWinInfo(QueryInfo info) szVersion+="Windows 95 ";
if (osvi.szCSDVersion[1]=='C' || osvi.szCSDVersion[1]=='B')
szVersion+="OSR2 ";
- }
+ }
if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10)
{
szVersion+="Windows 98 ";
if ( osvi.szCSDVersion[1]=='A' || osvi.szCSDVersion[1]=='B')
szVersion+="SE ";
- }
+ }
if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90)
{
szVersion+="Windows Millennium Edition";
- }
+ }
break;
case VER_PLATFORM_WIN32s:
@@ -403,7 +403,7 @@ static QString queryWinInfo(QueryInfo info) szMinor.setNum(minor);
szRelease.setNum(release);
szVersion = "Release : "+szMajor +"."+ szMinor +"."+ szRelease;
- return szVersion;
+ return szVersion;
}
if(info==Os_Type)
{
@@ -448,7 +448,7 @@ namespace KviOsInfo #endif
#endif
}
-
+
QString version()
{
#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)
@@ -460,7 +460,7 @@ namespace KviOsInfo return KviQString::empty;
#endif
}
-
+
QString release()
{
#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)
@@ -472,7 +472,7 @@ namespace KviOsInfo return KviQString::empty;
#endif
}
-
+
QString machine()
{
#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)
@@ -485,7 +485,7 @@ namespace KviOsInfo return KviQString::empty;
#endif
}
-
+
QString nodename()
{
#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)
@@ -497,7 +497,7 @@ namespace KviOsInfo return KviQString::empty;
#endif
}
-
+
QString hostname()
{
char hbuffer[1024];
diff --git a/src/kvilib/ext/kvi_pixmap.cpp b/src/kvilib/ext/kvi_pixmap.cpp index 8d31b4e96..8a1541c2d 100644 --- a/src/kvilib/ext/kvi_pixmap.cpp +++ b/src/kvilib/ext/kvi_pixmap.cpp @@ -23,7 +23,6 @@ //============================================================================= -#define __KVILIB__ #include "kvi_debug.h" @@ -108,7 +107,7 @@ void KviPixmap::set(const QPixmap &pix,const QString &szPath) setNull(); return; } - + if(m_pPix)delete m_pPix; m_pPix = new QPixmap(pix); m_szPath = szPath; @@ -155,21 +154,21 @@ void KviPixmapUtils::drawPixmapWithPainter(QPainter* p,QPixmap * pix,int flags,c int iPixHeight=pix->height(); int x=0; int y=0; - + if( !(flags & Qt::AlignHorizontal_Mask )) x=-1; else if ( flags & Qt::AlignRight ) x=iWidgetWidth - iPixWidth; else if( flags & Qt::AlignHCenter ) x=(iWidgetWidth - iPixWidth)/2; - + if( !(flags & Qt::AlignVertical_Mask )) y=-1; else if ( flags & Qt::AlignBottom ) y=iWidgetHeight - iPixHeight; else if( flags & Qt::AlignVCenter ) y=(iWidgetHeight - iPixHeight)/2; - + if(x==-1) { p->drawTiledPixmap(paintRect.left(),y,paintRect.width(),iPixHeight,*pix,dx,dy); } else if(y==-1) { diff --git a/src/kvilib/ext/kvi_proxydb.cpp b/src/kvilib/ext/kvi_proxydb.cpp index e7103ac60..b64bb3315 100644 --- a/src/kvilib/ext/kvi_proxydb.cpp +++ b/src/kvilib/ext/kvi_proxydb.cpp @@ -20,7 +20,6 @@ // Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // -#define __KVILIB__ #include "kvi_proxydb.h" diff --git a/src/kvilib/ext/kvi_regchan.cpp b/src/kvilib/ext/kvi_regchan.cpp index e5f189e95..667f8ed7f 100644 --- a/src/kvilib/ext/kvi_regchan.cpp +++ b/src/kvilib/ext/kvi_regchan.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_regchan.h" #include "kvi_config.h" @@ -107,7 +106,7 @@ KviRegisteredChannel * KviRegisteredChannelDataBase::find(const char * name,cons { if(kvi_matchString(c->netMask().ptr(),net))return c; } - + return 0; } diff --git a/src/kvilib/ext/kvi_regusersdb.cpp b/src/kvilib/ext/kvi_regusersdb.cpp index 539a627d8..f20ca8195 100644 --- a/src/kvilib/ext/kvi_regusersdb.cpp +++ b/src/kvilib/ext/kvi_regusersdb.cpp @@ -23,7 +23,6 @@ //================================================================================================= -#define __KVILIB__ #define _KVI_REGUSERDB_CPP_ #include "kvi_debug.h" @@ -309,7 +308,7 @@ KviRegisteredUserDataBase::KviRegisteredUserDataBase() m_pMaskDict = new KviPointerHashTable<QString,KviRegisteredMaskList>(49,false); // copy keys here! m_pMaskDict->setAutoDelete(true); - + m_pGroupDict = new KviPointerHashTable<QString,KviRegisteredUserGroup>(5,false); // copy keys here! m_pGroupDict->setAutoDelete(true); } @@ -468,11 +467,11 @@ void KviRegisteredUserDataBase::copyFrom(KviRegisteredUserDataBase * db) u->setGroup(theCur->group()); ++it; } - + KviPointerHashTableIterator<QString,KviRegisteredUserGroup> git(*db->m_pGroupDict); while(git.current()) { - addGroup(git.currentKey()); + addGroup(git.currentKey()); ++git; } } @@ -632,7 +631,7 @@ KviRegisteredMask * KviRegisteredUserDataBase::findExactMask(const KviIrcMask &m } /* bool KviRegisteredUserDataBase::isIgnoredUser(const QString & nick,const QString & user,const QString & host) -{ +{ KviRegisteredUser * u = findMatchingUser(nick,user,host); if(u)return u->getBoolProperty("IGNORE"); else return false; @@ -654,7 +653,7 @@ void KviRegisteredUserDataBase::load(const QString & filename) addGroup(szCurrent); } else { KviRegisteredUser * u = addUser(szCurrent); - + if(u) { u->setIgnoreEnabled(cfg.readBoolEntry("IgnoreEnabled",false)); @@ -724,7 +723,7 @@ void KviRegisteredUserDataBase::save(const QString & filename) cfg.writeEntry("Group",it.current()->group()); ++it; } - + KviPointerHashTableIterator<QString,KviRegisteredUserGroup> git(*m_pGroupDict); QString szTmp; while(git.current()) diff --git a/src/kvilib/ext/kvi_sharedfiles.cpp b/src/kvilib/ext/kvi_sharedfiles.cpp index a6babc7ef..e5c28079f 100644 --- a/src/kvilib/ext/kvi_sharedfiles.cpp +++ b/src/kvilib/ext/kvi_sharedfiles.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_sharedfiles.h" @@ -227,7 +226,7 @@ void KviSharedFilesManager::addSharedFile(KviSharedFile * f) l->setAutoDelete(true); m_pSharedListDict->replace(f->name(),l); } - + doInsert(l,f); if(((int)f->expireTime()) > 0) @@ -251,7 +250,7 @@ KviSharedFile * KviSharedFilesManager::addSharedFile(const QString &szName,const l->setAutoDelete(true); m_pSharedListDict->replace(szName,l); } - + // Now insert KviSharedFile * o = new KviSharedFile(szName,szAbsPath,szMask,timeoutInSecs > 0 ? (((int)(time(0))) + timeoutInSecs) : 0,inf.size()); diff --git a/src/kvilib/ext/kvi_stringconversion.cpp b/src/kvilib/ext/kvi_stringconversion.cpp index ab2368cd5..7e7bf2514 100644 --- a/src/kvilib/ext/kvi_stringconversion.cpp +++ b/src/kvilib/ext/kvi_stringconversion.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #define _KVI_STRINGCONVERSION_CPP_ @@ -88,7 +87,7 @@ namespace KviStringConversion } } } - + void encodePath(QStringList& buffer) { for ( QStringList::Iterator it = buffer.begin(); it != buffer.end(); ++it ) @@ -109,7 +108,7 @@ namespace KviStringConversion { buffer = bValue ? '1' : '0'; } - + bool fromString(const QString & szValue,bool &buffer) { if(szValue.isEmpty())buffer = false; @@ -121,31 +120,31 @@ namespace KviStringConversion { buffer.setNum(iValue); } - + bool fromString(const QString &szValue,int &buffer) { bool bOk; buffer = szValue.toInt(&bOk); return bOk; } - + void toString(const unsigned int uValue,QString &buffer) { buffer.setNum(uValue); } - + bool fromString(const QString & szValue,unsigned int &buffer) { bool bOk; buffer= szValue.toUInt(&bOk); return bOk; } - + void toString(const QRect &rValue,QString &buffer) { buffer.sprintf("%d,%d,%d,%d",rValue.x(),rValue.y(),rValue.width(),rValue.height()); } - + bool fromString(const QString & szValue,QRect &buffer) { KviQCString tmp = KviQString::toUtf8(szValue); @@ -156,24 +155,24 @@ namespace KviStringConversion buffer.setRect(l,t,w,h); return true; } - + void toString(const QString &szValue,QString &buffer) { buffer = szValue; } - + bool fromString(const QString & szValue,QString &buffer) { buffer = szValue; return true; } - + void toString(const KviPixmap &pValue,QString &buffer) { buffer=pValue.path(); encodePath(buffer); } - + bool fromString(const QString & szValue,KviPixmap &buffer) { QString szPath(szValue); @@ -185,12 +184,12 @@ namespace KviStringConversion return buffer.load(szPath); } } - + void toString(const KviMsgType &mValue,QString &buffer) { buffer.sprintf("%d,%u,%u,%d,%d",mValue.m_iPixId,mValue.m_cForeColor,mValue.m_cBackColor,mValue.m_bLogEnabled,mValue.m_iLevel); } - + bool fromString(const QString & szValue,KviMsgType &buffer) { int iId,iLog,iLevel; @@ -202,17 +201,17 @@ namespace KviStringConversion buffer = KviMsgType(buffer.m_szType,iId,uFore,uBack,iLog,iLevel); return true; } - + void toString(const QColor &cValue,QString &buffer) { buffer = cValue.name(); } - + bool fromString(const QString & szValue,QColor &buffer) { buffer.setNamedColor(szValue); return true; } - + void toString(const QFont &fValue,QString &buffer) { QString family(fValue.family()); @@ -223,14 +222,14 @@ namespace KviStringConversion if(fValue.underline())options.append('u'); if(fValue.strikeOut())options.append('s'); if(fValue.fixedPitch())options.append('f'); - + if(!options.isEmpty()) { buffer.append(','); buffer.append(options); } } - + bool fromString(const QString & szValue,QFont &buffer) { KviStr str = szValue; @@ -238,7 +237,7 @@ namespace KviStringConversion str.getToken(family,','); str.getToken(pointSize,','); str.getToken(styleHint,','); - str.getToken(weight,','); + str.getToken(weight,','); if(!family.isEmpty())buffer.setFamily(family.ptr()); int i; bool bOk; @@ -258,12 +257,12 @@ namespace KviStringConversion } return true; } - + void toString(const QStringList &sValue,QString &buffer) { buffer = sValue.join(","); } - + bool fromString(const QString & szValue,QStringList &buffer) { buffer = szValue.split(","); diff --git a/src/kvilib/file/kvi_file.cpp b/src/kvilib/file/kvi_file.cpp index c4a6bf712..b51e766d7 100644 --- a/src/kvilib/file/kvi_file.cpp +++ b/src/kvilib/file/kvi_file.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_file.h" diff --git a/src/kvilib/file/kvi_fileutils.cpp b/src/kvilib/file/kvi_fileutils.cpp index 8fec5c2c2..d9e577a84 100644 --- a/src/kvilib/file/kvi_fileutils.cpp +++ b/src/kvilib/file/kvi_fileutils.cpp @@ -22,7 +22,6 @@ //
//=============================================================================
-#define __KVILIB__
#define _KVI_FILEUTLIS_CPP_
diff --git a/src/kvilib/file/kvi_packagefile.cpp b/src/kvilib/file/kvi_packagefile.cpp index ce4332b86..d45cd267c 100644 --- a/src/kvilib/file/kvi_packagefile.cpp +++ b/src/kvilib/file/kvi_packagefile.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_packagefile.h" #include "kvi_file.h" @@ -54,7 +53,7 @@ // Magic Bytes 4 'KVPF': Signature for the Kvirc Package File // Version uint32 4 0x00000001: Version of this package file // Flags uint32 4 0x00000000: Flags, in version 1 is reserved and must be zero -// +// // PackageInfo: // InfoFieldCount uint32 4 Number of package info fields @@ -72,7 +71,7 @@ // InfoField: // Name UniString Variable The "name" element of the info field // ValueType uint32 4 The type of the following ValueData field -// ValueData ValueData Variable +// ValueData ValueData Variable // ValueData for ValueType 1 (string field) // Value UniString Variable The value element of type string of the the info field @@ -205,7 +204,7 @@ bool KviPackageWriter::addFileInternal(const QFileInfo * fi,const QString &szLoc { if(!(fi->isFile() && fi->isReadable())) return false; - + if(!(uAddFileFlags & FollowSymLinks)) { if(fi->isSymLink()) @@ -218,7 +217,7 @@ bool KviPackageWriter::addFileInternal(const QFileInfo * fi,const QString &szLoc f->m_szFileLocalName = szLocalFileName; f->m_szFileTargetName = szTargetFileName; m_pDataFields->append(f); - + return true; } @@ -291,7 +290,7 @@ bool KviPackageWriter::packFile(KviFile * pFile,DataField * pDataField) // Flags #ifdef COMPILE_ZLIB_SUPPORT - kvi_u32_t uFlags = pDataField->m_bFileAllowCompression ? + kvi_u32_t uFlags = pDataField->m_bFileAllowCompression ? (uSize > 64 ? KVI_PACKAGE_DATAFIELD_FLAG_FILE_DEFLATE : 0) : 0; #else @@ -318,11 +317,11 @@ bool KviPackageWriter::packFile(KviFile * pFile,DataField * pDataField) { unsigned char ibuffer[BUFFER_SIZE]; unsigned char obuffer[BUFFER_SIZE]; - + kvi_i32_t iReaded = source.readBlock((char *)ibuffer,BUFFER_SIZE); if(iReaded < 0) return readError(); - + z_stream zstr; zstr.zalloc = Z_NULL; zstr.zfree = Z_NULL; @@ -337,18 +336,18 @@ bool KviPackageWriter::packFile(KviFile * pFile,DataField * pDataField) setLastError(__tr2qs("Compression library initialization error")); return false; } - + while(iReaded > 0) { zstr.next_out = obuffer; zstr.avail_out = BUFFER_SIZE; - + if(deflate(&zstr,Z_NO_FLUSH) != Z_OK) { setLastError(__tr2qs("Compression library error")); return false; } - + if(zstr.avail_out < BUFFER_SIZE) { int iCompressed = zstr.next_out - obuffer; @@ -359,7 +358,7 @@ bool KviPackageWriter::packFile(KviFile * pFile,DataField * pDataField) return writeError(); } } - + if(zstr.avail_in < BUFFER_SIZE) { int iDataToRead = BUFFER_SIZE - zstr.avail_in; @@ -380,7 +379,7 @@ bool KviPackageWriter::packFile(KviFile * pFile,DataField * pDataField) } zstr.avail_in += iReaded; zstr.next_in = ibuffer; - + if((zstr.total_in % 2000000) == 0) { QString szTmp; @@ -391,16 +390,16 @@ bool KviPackageWriter::packFile(KviFile * pFile,DataField * pDataField) } } } - + // flush pending output zstr.next_out = obuffer; zstr.avail_out = BUFFER_SIZE; - + int ret; do { ret = deflate(&zstr,Z_FINISH); - + if((ret == Z_OK) || (ret == Z_STREAM_END)) { if(zstr.avail_out < BUFFER_SIZE) @@ -421,7 +420,7 @@ bool KviPackageWriter::packFile(KviFile * pFile,DataField * pDataField) zstr.next_out = obuffer; zstr.avail_out = BUFFER_SIZE; } - + } while(ret == Z_OK); // store the compressed data size @@ -514,7 +513,7 @@ bool KviPackageWriter::packInternal(const QString &szFileName,kvi_u32_t uPackFla if(!f.save(uFlags))return writeError(); // write PackageInfo - + // InfoFieldCount kvi_u32_t uCount = m_pStringInfoFields->count() + m_pBinaryInfoFields->count(); if(!f.save(uCount))return writeError(); @@ -522,7 +521,7 @@ bool KviPackageWriter::packInternal(const QString &szFileName,kvi_u32_t uPackFla m_iCurrentProgress = 5; if(!updateProgress(m_iCurrentProgress,__tr2qs("Writing informational fields"))) return false; // aborted - + // InfoFields (string) KviPointerHashTableIterator<QString,QString> it(*m_pStringInfoFields); while(QString * s = it.current()) @@ -533,7 +532,7 @@ bool KviPackageWriter::packInternal(const QString &szFileName,kvi_u32_t uPackFla if(!f.save(*s))return writeError(); ++it; } - + // InfoFields (binary) KviPointerHashTableIterator<QString,QByteArray> it2(*m_pBinaryInfoFields); while(QByteArray * b = it2.current()) @@ -555,7 +554,7 @@ bool KviPackageWriter::packInternal(const QString &szFileName,kvi_u32_t uPackFla { kvi_u32_t uDataFieldType = pDataField->m_uType; if(!f.save(uDataFieldType))return writeError(); - + kvi_file_offset_t savedLenOffset = f.pos(); // here we will store the length of the field once it's written if(!f.save(uDataFieldType))return writeError(); @@ -573,7 +572,7 @@ bool KviPackageWriter::packInternal(const QString &szFileName,kvi_u32_t uPackFla return false; break; } - + kvi_file_offset_t savedEndOffset = f.pos(); f.seek(savedLenOffset); if(!f.save(pDataField->m_uWrittenFieldLength)) @@ -627,7 +626,7 @@ bool KviPackageReader::readHeaderInternal(KviFile * pFile,const QString &szLocal // we ignore them at the moment // read PackageInfo - + // InfoFieldCount kvi_u32_t uCount; if(!pFile->load(uCount))return writeError(); @@ -710,7 +709,7 @@ bool KviPackageReader::unpackFile(KviFile * pFile,const QString &szUnpackPath) // no attacks please :) szFileName.replace(QString("..\\"),QString("")); szFileName.replace(QString("..//"),QString("")); - + KviFileUtils::adjustFilePath(szFileName); int idx = KviQString::findRev(szFileName,QChar(KVI_PATH_SEPARATOR_CHAR)); @@ -753,7 +752,7 @@ bool KviPackageReader::unpackFile(KviFile * pFile,const QString &szUnpackPath) if(iToRead > BUFFER_SIZE)iToRead = BUFFER_SIZE; int iReaded = pFile->readBlock((char *)ibuffer,iToRead); iRemainingSize -= iReaded; - + z_stream zstr; zstr.zalloc = Z_NULL; zstr.zfree = Z_NULL; @@ -762,24 +761,24 @@ bool KviPackageReader::unpackFile(KviFile * pFile,const QString &szUnpackPath) zstr.avail_in = iReaded; zstr.next_out = obuffer; zstr.avail_out = BUFFER_SIZE; - + if(inflateInit(&zstr) != Z_OK) { setLastError(__tr2qs("Compression library initialization error")); return false; } - + while((iReaded > 0) && (iRemainingSize > 0)) { zstr.next_out = obuffer; zstr.avail_out = BUFFER_SIZE; - + if(inflate(&zstr,Z_NO_FLUSH) != Z_OK) { setLastError(__tr2qs("Compression library error")); return false; } - + if(zstr.avail_out < BUFFER_SIZE) { int iDecompressed = zstr.next_out - obuffer; @@ -789,7 +788,7 @@ bool KviPackageReader::unpackFile(KviFile * pFile,const QString &szUnpackPath) return writeError(); } } - + if(zstr.avail_in < BUFFER_SIZE) { int iDataToRead = BUFFER_SIZE - zstr.avail_in; @@ -802,7 +801,7 @@ bool KviPackageReader::unpackFile(KviFile * pFile,const QString &szUnpackPath) memmove(ibuffer,zstr.next_in,zstr.avail_in); } } - + if(iDataToRead > iRemainingSize) iDataToRead = iRemainingSize; @@ -816,7 +815,7 @@ bool KviPackageReader::unpackFile(KviFile * pFile,const QString &szUnpackPath) iRemainingSize -= iReaded; zstr.avail_in += iReaded; zstr.next_in = ibuffer; - + if((zstr.total_in % 2000000) == 0) { QString szTmp; @@ -827,16 +826,16 @@ bool KviPackageReader::unpackFile(KviFile * pFile,const QString &szUnpackPath) } } } - + // flush pending output zstr.next_out = obuffer; zstr.avail_out = BUFFER_SIZE; - + int ret; do { ret = inflate(&zstr,Z_FINISH); - + if((ret == Z_OK) || (ret == Z_STREAM_END) || (ret == Z_BUF_ERROR)) { if(zstr.avail_out < BUFFER_SIZE) @@ -849,7 +848,7 @@ bool KviPackageReader::unpackFile(KviFile * pFile,const QString &szUnpackPath) } } /* else { THIS HAPPENS FOR ZERO SIZE FILES debug("hum.... internal, rEWq (ret = %d) (avail_out = %d)",ret,zstr.avail_out); - + inflateEnd(&zstr); setLastError(__tr2qs("Compression library internal error")); return false; @@ -859,7 +858,7 @@ bool KviPackageReader::unpackFile(KviFile * pFile,const QString &szUnpackPath) } } while((ret == Z_OK) || (ret == Z_BUF_ERROR)); - + inflateEnd(&zstr); if(ret != Z_STREAM_END) @@ -957,7 +956,7 @@ bool KviPackageReader::unpackInternal(const QString &szLocalFileName,const QStri // DataFieldLen kvi_u32_t uDataFieldLen; if(!f.load(uDataFieldLen))return readError(); - + switch(uDataFieldType) { case KVI_PACKAGE_DATAFIELD_TYPE_FILE: @@ -969,7 +968,7 @@ bool KviPackageReader::unpackInternal(const QString &szLocalFileName,const QStri return false; break; } - + } return true; diff --git a/src/kvilib/irc/kvi_avatar.cpp b/src/kvilib/irc/kvi_avatar.cpp index 4f48dbf15..d0b1c9255 100644 --- a/src/kvilib/irc/kvi_avatar.cpp +++ b/src/kvilib/irc/kvi_avatar.cpp @@ -21,14 +21,12 @@ // Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // //============================================================================= -#define __KVILIB__ - #include "kvi_avatar.h" #include "kvi_qstring.h" #include <QImage> - +#include <QImageReader> /* @doc: ctcp_avatar @@ -95,44 +93,51 @@ The "preferred" image size may grow with time, as the network transmission speed grows. */ -KviAvatar::KviAvatar(const QString &szLocalPath,const QString &szName,QPixmap * pix) +KviAvatar::KviAvatar( + const QString &szLocalPath, + const QString &szName, + const QSize& scaleOnLoad) { - m_pScaledPixmap = 0; - m_pPixmap = pix ? pix : new QPixmap(32,32); m_bRemote = KviQString::equalCIN("http://",szName,7); m_szLocalPath = szLocalPath; m_szName = szName; + + m_pPixmap = new KviAnimatedPixmap(szLocalPath); + + if(scaleOnLoad.isValid() && ( + scaleOnLoad.height() < size().height() || + scaleOnLoad.width() < size().width() + ) + ) + { + m_pPixmap->resize(scaleOnLoad,Qt::KeepAspectRatio); + } + + m_pPixmap->start(); + + m_scaledPixmapsCache.insert(m_pPixmap->size(),m_pPixmap); } KviAvatar::~KviAvatar() { - delete m_pPixmap; - if(m_pScaledPixmap)delete m_pScaledPixmap; + foreach(KviAnimatedPixmap* pix,m_scaledPixmapsCache) + { + delete pix; + } } -QPixmap * KviAvatar::scaledPixmap(unsigned int w,unsigned int h) +KviAnimatedPixmap * KviAvatar::forSize(const QSize& size) { - // To supress compiler warning we make a cast to int (QPixmap::width and - // QPixmap::height return ints). - // This can be avoided by changing function parameter type to int - int width = static_cast<int>(w); - int height = static_cast<int>(h); - if ((m_pPixmap->width() == width) && (m_pPixmap->height() == height)) + if(m_scaledPixmapsCache.contains(size)) { - return m_pPixmap; + return m_scaledPixmapsCache[size]; } - // look if we have cached result - if (m_pScaledPixmap) - { - if ((m_pScaledPixmap->width() == width) && (m_pScaledPixmap->height() == height)) - { - return m_pScaledPixmap; - } - delete m_pScaledPixmap; - m_pScaledPixmap = 0; - } - m_pScaledPixmap = new QPixmap(m_pPixmap->scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation)); - return m_pScaledPixmap; + + KviAnimatedPixmap* scaledPixmap = new KviAnimatedPixmap(m_pPixmap); + scaledPixmap->resize(size,Qt::KeepAspectRatio); + + m_scaledPixmapsCache.insert(scaledPixmap->size(),scaledPixmap); + return scaledPixmap; } diff --git a/src/kvilib/irc/kvi_avatar.h b/src/kvilib/irc/kvi_avatar.h index 64fd58073..46c47d237 100644 --- a/src/kvilib/irc/kvi_avatar.h +++ b/src/kvilib/irc/kvi_avatar.h @@ -28,28 +28,96 @@ #include "kvi_heapobject.h" #include "kvi_settings.h" +#include "kvi_animatedpixmap.h" + #include <QPixmap> +#include <QHash> + +inline uint qHash(const QSize& s) { return uint(s.width() | s.height()); } class KVILIB_API KviAvatar : public KviHeapObject { public: - KviAvatar(const QString &szLocalPath,const QString &szName,QPixmap * pix); + KviAvatar(const QString &szLocalPath, + const QString &szName, + const QSize& scaleOnLoad = QSize()); ~KviAvatar(); + private: - QString m_szLocalPath; - QString m_szName; - bool m_bRemote; + QString m_szLocalPath; + QString m_szName; + bool m_bRemote; + + KviAnimatedPixmap * m_pPixmap; + QHash<QSize,KviAnimatedPixmap*> m_scaledPixmapsCache; - QPixmap * m_pPixmap; - QPixmap * m_pScaledPixmap; public: - QPixmap * pixmap(){ return m_pPixmap; }; - QPixmap * scaledPixmap(unsigned int w,unsigned int h); - bool isRemote(){ return m_bRemote; }; + /* + * Returns true, if avatar is remote. + */ + inline bool isRemote() { + return m_bRemote; + } + + /* + * Returns filepath + */ + inline const QString &localPath() { + return m_szLocalPath; + } + + /* + * Returns fiename. For remote avatars, remote address will be returned. + */ + inline const QString &name() { + return m_szName; + } + + /* + * Returns true, if underlying pixmap contains more, then one frame. + */ + inline bool isAnimated() { + return (m_pPixmap->framesCount() > 1); + } + + /* + * Returns original pixmap's size + */ + inline const QSize& size() { + return m_pPixmap->size(); + } + + /* + * Returns unscaled original frame. + */ + inline QPixmap* pixmap() { + return m_pPixmap->pixmap(); + } + + /* + * Returns original animated pixmap. + */ + inline KviAnimatedPixmap * animatedPixmap() { + return m_pPixmap; + } + + /* + * Returns animated pixmap, scaled to the requisted size. + * Scaling automagically keeps aspect ratio. + * Scaled image cached. + * + * KviAvatar takes ownership on it, and will automatically delete it + * in destructor. + * + * It is safe to connect returned KviAnimatedPixmap signals to external + * slots. + */ - const QString &localPath(){ return m_szLocalPath; }; - const QString &name(){ return m_szName; }; + KviAnimatedPixmap * forSize(const QSize& size); + inline KviAnimatedPixmap * forSize(unsigned int w, unsigned int h) { + return forSize(QSize(w,h)); + } // string that uniquely identifies this avatar // for remote avatars that have name starting with http:// diff --git a/src/kvilib/irc/kvi_avatarcache.cpp b/src/kvilib/irc/kvi_avatarcache.cpp index 4de5d6c72..11b11ce97 100644 --- a/src/kvilib/irc/kvi_avatarcache.cpp +++ b/src/kvilib/irc/kvi_avatarcache.cpp @@ -21,8 +21,6 @@ // Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // //============================================================================= -#define __KVILIB__ - #include "kvi_avatarcache.h" #include "kvi_pointerlist.h" @@ -47,7 +45,7 @@ void KviAvatarCache::init() debug("WARNING: trying to initialize the avatar cache twice"); return; } - + m_pAvatarCacheInstance = new KviAvatarCache(); } @@ -58,7 +56,7 @@ void KviAvatarCache::done() debug("WARNING: trying to destroy an uninitialized avatar cache"); return; } - + delete m_pAvatarCacheInstance; m_pAvatarCacheInstance = 0; } @@ -83,13 +81,13 @@ void KviAvatarCache::replace(const QString &szIdString,const KviIrcMask &mask,co mask.mask(szKey,KviIrcMask::NickCleanUserSmartNet); szKey.append(QChar('+')); szKey.append(szNetwork); - + KviAvatarCacheEntry * e = new KviAvatarCacheEntry; e->szIdString = szIdString; e->tLastAccess = kvi_unixTime(); - + m_pAvatarDict->replace(szKey,e); - + if(m_pAvatarDict->count() > MAX_AVATARS_IN_CACHE) { cleanup(); @@ -103,7 +101,7 @@ void KviAvatarCache::remove(const KviIrcMask &mask,const QString &szNetwork) mask.mask(szKey,KviIrcMask::NickCleanUserSmartNet); szKey.append(QChar('+')); szKey.append(szNetwork); - + m_pAvatarDict->remove(szKey); } @@ -132,9 +130,9 @@ void KviAvatarCache::load(const QString &szFileName) kvi_time_t tNow = kvi_unixTime(); KviConfigIterator it(*(cfg.dict())); - + int cnt = 0; - + while(it.current()) { cfg.setGroup(it.currentKey()); @@ -181,7 +179,7 @@ void KviAvatarCache::cleanup() { // first do a quick run deleting the avatars really too old KviPointerHashTableIterator<QString,KviAvatarCacheEntry> it(*m_pAvatarDict); - + kvi_time_t tNow = kvi_unixTime(); KviPointerList<QString> l; @@ -197,21 +195,21 @@ void KviAvatarCache::cleanup() } ++it; } - + for(QString *s = l.first();s;s = l.next())m_pAvatarDict->remove(*s); if(m_pAvatarDict->count() < CACHE_GUARD_LEVEL)return; - + // not done.. need to kill the last accessed :/ it.toFirst(); - + KviPointerList<KviAvatarCacheEntry> ll; ll.setAutoDelete(true); // here we use the cache entries in another way // szAvatar is the KEY instead of the avatar name - + while((e = it.current())) { KviAvatarCacheEntry * current = ll.first(); @@ -235,7 +233,7 @@ void KviAvatarCache::cleanup() else ll.append(xx); ++it; } - + // the oldest keys are at the beginning int uRemove = ll.count() - CACHE_GUARD_LEVEL; if(uRemove < 1)return; // huh ? diff --git a/src/kvilib/irc/kvi_ircmask.cpp b/src/kvilib/irc/kvi_ircmask.cpp index 3ff198711..68cb88e61 100644 --- a/src/kvilib/irc/kvi_ircmask.cpp +++ b/src/kvilib/irc/kvi_ircmask.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_debug.h" @@ -274,7 +273,7 @@ KviIrcMask::KviIrcMask(const QString &szMask) } else { m_szHost = szWild; // ??? } - + } else { m_szUser = szWild; m_szHost = szWild; @@ -319,7 +318,7 @@ bool KviIrcMask::hasNumericHost() const * 1 : nick!user@*.host.top (nick!user@XXX.XXX.XXX.*)<br> * 2 : nick!user@*<br> * 3 : nick!*@machine.host.top (nick!user@XXX.XXX.XXX.XXX)<br> -* 4 : nick!*@*.host.top (nick!user@XXX.XXX.XXX.*)<br> +* 4 : nick!*@*.host.top (nick!user@XXX.XXX.XXX.*)<br> * 5 : nick!*@*<br> * 6 : *!user@machine.host.top (*!user@XXX.XXX.XXX.XX)<br> * 7 : *!user@*.host.top (*!user@XXX.XXX.XXX.*)<br> diff --git a/src/kvilib/irc/kvi_ircserver.cpp b/src/kvilib/irc/kvi_ircserver.cpp index 0113d49d4..57a3e79b2 100644 --- a/src/kvilib/irc/kvi_ircserver.cpp +++ b/src/kvilib/irc/kvi_ircserver.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_ircserver.h" #include "kvi_malloc.h" diff --git a/src/kvilib/irc/kvi_ircserverdb.cpp b/src/kvilib/irc/kvi_ircserverdb.cpp index 672dfefd9..3d7f9f476 100644 --- a/src/kvilib/irc/kvi_ircserverdb.cpp +++ b/src/kvilib/irc/kvi_ircserverdb.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include <QApplication> @@ -172,7 +171,7 @@ bool KviServerDataBase::makeCurrentBestServerInNetwork(const QString &szNetName, { m_szCurrentNetwork = szNetName; // find a round-robin server in that network - + if(r->m_pServerList->isEmpty()) { szError = __tr2qs("The specified network has no server entries"); @@ -253,9 +252,9 @@ bool KviServerDataBase::makeCurrentServer(KviServerDefinition * d,QString &szErr szError = __tr2qs("The server specification seems to be in the id:<string> form but the identifier coulnd't be found in the database"); return false; } - + it.toFirst(); - + while((r = it.current())) { for(srv = r->serverList()->first();srv && (!pServer);srv = r->serverList()->next()) @@ -321,7 +320,7 @@ search_finished: if(!d->szNick.isEmpty())pServer->m_szNick = d->szNick; if(!d->szPass.isEmpty())pServer->m_szPass = d->szPass; // don't clear the pass! if(!d->szInitUMode.isEmpty())pServer->m_szInitUMode = d->szInitUMode; - + m_szCurrentNetwork = r->network()->name(); r->setCurrentServer(pServer); return true; @@ -384,10 +383,10 @@ search_finished: r->insertServer(s); m_szCurrentNetwork = r->network()->name(); r->setCurrentServer(s); - + return true; } - + void parseMircServerRecord(QString entry,QString& szNet, QString& szDescription,QString& szHost,QString& szPort,bool& bSsl,kvi_u32_t& uPort) { @@ -482,7 +481,7 @@ void KviServerDataBase::loadFromMircIni(const QString & filename, const QString // <net>:<description>SERVER:<server:port>GROUP:<group???> if(entry==szDefaultServer) bDefault = true; - + parseMircServerRecord(entry,szNet, szDescription,szHost,szPort,bSsl,uPort); @@ -497,7 +496,7 @@ void KviServerDataBase::loadFromMircIni(const QString & filename, const QString s->m_szHostname = szHost; s->m_szDescription = szDescription; s->m_uPort = uPort; - + r->m_pServerList->append(s); if(bDefault) diff --git a/src/kvilib/irc/kvi_ircuserdb.cpp b/src/kvilib/irc/kvi_ircuserdb.cpp index 6b7f2b53f..291323d17 100644 --- a/src/kvilib/irc/kvi_ircuserdb.cpp +++ b/src/kvilib/irc/kvi_ircuserdb.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_debug.h" @@ -177,7 +176,7 @@ KviRegisteredUser* KviIrcUserDataBase::registeredUser(const QString & nick,const u->m_bUseCustomColor=pUser->getBoolProperty("useCustomColor"); QString szTmp=pUser->getProperty("customColor"); KviStringConversion::fromString(szTmp,u->m_cachedColor); - + u->m_bNotFoundRegUserLoockup=false; //to be shure } else { u->m_szLastRegisteredMatchNick=nick; diff --git a/src/kvilib/irc/kvi_mirccntrl.cpp b/src/kvilib/irc/kvi_mirccntrl.cpp index 128399eb6..4a96f7b29 100644 --- a/src/kvilib/irc/kvi_mirccntrl.cpp +++ b/src/kvilib/irc/kvi_mirccntrl.cpp @@ -20,7 +20,6 @@ // Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // -#define __KVILIB__ #define _KVI_MIRCCNTRL_CPP_ @@ -254,7 +253,7 @@ namespace KviMircCntrl QString stripControlBytes(const QString &szData) { QString ret; - + int i = 0; int l = szData.length(); int begin = 0; diff --git a/src/kvilib/irc/kvi_nickserv.cpp b/src/kvilib/irc/kvi_nickserv.cpp index 3fc0e8d68..12b5e17d3 100644 --- a/src/kvilib/irc/kvi_nickserv.cpp +++ b/src/kvilib/irc/kvi_nickserv.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_nickserv.h" diff --git a/src/kvilib/irc/kvi_useridentity.cpp b/src/kvilib/irc/kvi_useridentity.cpp index 9a49a5b09..c9a0d6861 100644 --- a/src/kvilib/irc/kvi_useridentity.cpp +++ b/src/kvilib/irc/kvi_useridentity.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_useridentity.h" #include "kvi_locale.h" @@ -83,7 +82,7 @@ void KviUserIdentity::copyFrom(const KviUserIdentity &src) { m_szId = src.m_szId; m_szNickName = src.m_szNickName; - + m_szAltNickName1 = src.m_szAltNickName1; m_szAltNickName2 = src.m_szAltNickName2; m_szAltNickName3 = src.m_szAltNickName3; @@ -91,26 +90,26 @@ void KviUserIdentity::copyFrom(const KviUserIdentity &src) m_szUserName = src.m_szUserName; m_szRealName = src.m_szRealName; m_szPassword = src.m_szPassword; - + m_pixAvatar = src.m_pixAvatar; m_szUserName = src.m_szUserName; m_szRealName = src.m_szRealName; m_szPassword = src.m_szPassword; - + m_pixAvatar = src.m_pixAvatar; - + m_szPartMessage = src.m_szPartMessage; m_szQuitMessage = src.m_szQuitMessage; - + m_szAge = src.m_szAge; m_szGender = src.m_szGender; m_szLocation = src.m_szLocation; m_szLanguages = src.m_szLanguages; m_szOtherInfo = src.m_szOtherInfo; - + m_szUserMode = src.m_szUserMode; - + m_szOnConnectCommand = src.m_szOnConnectCommand; m_szOnLoginCommand = src.m_szOnLoginCommand; } @@ -173,9 +172,9 @@ const KviUserIdentity * KviUserIdentityManager::defaultIdentity() ret->setRealName(KVI_DEFAULT_REALNAME); ret->setPartMessage(KVI_DEFAULT_PART_MESSAGE); ret->setQuitMessage(KVI_DEFAULT_QUIT_MESSAGE); - + m_pIdentityDict->replace(ret->id(),ret); - + return ret; } @@ -186,7 +185,7 @@ void KviUserIdentityManager::load(const QString &szFileName) KviConfig cfg(szFileName,KviConfig::Read); cfg.setGroup("KVIrc"); - + m_szDefaultIdentity = cfg.readQStringEntry("DefaultIdentity",""); KviConfigIterator it(*(cfg.dict())); @@ -210,11 +209,11 @@ void KviUserIdentityManager::save(const QString &szFileName) { KviConfig cfg(szFileName,KviConfig::Write); cfg.clear(); - + cfg.setGroup("KVIrc"); cfg.writeEntry("DefaultIdentity",m_szDefaultIdentity); - + KviPointerHashTableIterator<QString,KviUserIdentity> it(*m_pIdentityDict); while(KviUserIdentity * id = it.current()) { diff --git a/src/kvilib/net/kvi_dns.cpp b/src/kvilib/net/kvi_dns.cpp index f46333981..a6ec22d1c 100644 --- a/src/kvilib/net/kvi_dns.cpp +++ b/src/kvilib/net/kvi_dns.cpp @@ -21,7 +21,6 @@ // Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // //============================================================================= -#define __KVILIB__ #include "kvi_dns.h" #include "kvi_error.h" @@ -101,7 +100,7 @@ int KviDnsThread::translateDnsError(int iErr) switch(iErr) { - case EAI_FAMILY: return KviError_unsupportedAddressFamily; break; + case EAI_FAMILY: return KviError_unsupportedAddressFamily; break; #if (!defined(COMPILE_ON_WINDOWS) && !defined(COMPILE_ON_MINGW)) && defined(EAI_ADDRFAMILY) && (EAI_ADDRFAMILY != EAI_FAMILY) case EAI_ADDRFAMILY: return KviError_unsupportedAddressFamily; break; #endif @@ -217,7 +216,7 @@ void KviDnsThread::run() } -#else +#else int retVal; @@ -269,7 +268,7 @@ void KviDnsThread::run() dns->appendHostname(retname); dns->appendAddress(m_szQuery); } - + } else { //#endif //HAVE_GETNAMEINFO diff --git a/src/kvilib/net/kvi_http.cpp b/src/kvilib/net/kvi_http.cpp index 2e4231390..c3898c580 100644 --- a/src/kvilib/net/kvi_http.cpp +++ b/src/kvilib/net/kvi_http.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include <QDir> @@ -543,7 +542,7 @@ bool KviHttpRequest::processHeader(KviStr &szHeader) { m_bGzip = contentEncoding->equalsCI("gzip"); } - + KviStr * transferEncoding = hdr.find("Transfer-Encoding"); if(transferEncoding) { @@ -644,7 +643,7 @@ void KviHttpRequest::processData(KviDataBuffer * data) { // time to process the header m_pBuffer->append(*data); - + int idx = m_pBuffer->find((const unsigned char *)"\r\n\r\n",4); if(idx == -1) { @@ -669,22 +668,22 @@ void KviHttpRequest::processData(KviDataBuffer * data) } m_uReceivedSize = m_pBuffer->size(); - + // here the header is complete and the eventual remaining data is in m_pBuffer. data has been already used. - + } else { // header already processed m_uReceivedSize += data->size(); - + // here the header is complete and some data *might* be already in m_pBuffer. data is unused yet. - + // Optimisation: If the transfer is NOT chunked (so we don't have to parse it) // and the requested processing type is either Blocks or StoreToFile // then we just can avoid to copy the data to m_pBuffer. // This is a good optimisation since for large files we can save allocating // space for and moving megabytes of data... - + if((!m_bChunkedTransferEncoding) && ((m_eProcessingType == Blocks) || (m_eProcessingType == StoreToFile))) { @@ -697,17 +696,17 @@ void KviHttpRequest::processData(KviDataBuffer * data) m_pFile->writeBlock((const char *)(data->data()),data->size()); break; } - + if(((m_uTotalSize > 0) && (m_uReceivedSize > m_uTotalSize)) || ((m_uMaxContentLength > 0) && (m_uReceivedSize > m_uMaxContentLength))) { resetInternalStatus(); m_szLastError=__tr2qs("Stream exceeded expected length"); emit terminated(false); } - + return; } - + // need to append to m_pBuffer and process it m_pBuffer->append(*data); } @@ -927,7 +926,7 @@ bool KviHttpRequestThread::selectForWrite(int iTimeoutInSecs) } fd_set writeSet; - + FD_ZERO(&writeSet); FD_SET(m_sock,&writeSet); @@ -935,10 +934,10 @@ bool KviHttpRequestThread::selectForWrite(int iTimeoutInSecs) struct timeval tmv; tmv.tv_sec = 0; tmv.tv_usec = 1000; // we wait 1000 usecs for an event - + int nRet = kvi_socket_select(m_sock + 1,0,&writeSet,0,&tmv); - + if(nRet > 0) { if(FD_ISSET(m_sock,&writeSet)) @@ -1034,7 +1033,7 @@ bool KviHttpRequestThread::connectToRemoteHost() return failure(__tr_no_lookup("Failed to initialize the SSL context")); if(!m_pSSL->initSocket(m_sock)) return failure(__tr_no_lookup("Failed to initialize the SSL connection")); - + for(;;) { switch(m_pSSL->connect()) @@ -1071,7 +1070,7 @@ bool KviHttpRequestThread::connectToRemoteHost() break; } } - + // never here return true; } @@ -1258,7 +1257,7 @@ bool KviHttpRequestThread::readDataStep() unsigned char buffer[2048]; int readed; - + #ifdef COMPILE_SSL_SUPPORT if(m_pSSL) { @@ -1330,10 +1329,10 @@ void KviHttpRequestThread::run() { // setup: // nothing needed - + // run: runInternal(); - + // cleanup: #ifdef COMPILE_SSL_SUPPORT if(m_pSSL) @@ -1373,7 +1372,7 @@ void KviHttpRequestThread::runInternal() case Post: szMethod = "POST"; break; case Get: szMethod = "GET"; break; } - + KviStr szRequest(KviStr::Format,"%s %s HTTP/1.1\r\n" \ "Host: %s\r\n" \ "Connection: Close\r\n" \ diff --git a/src/kvilib/net/kvi_netutils.cpp b/src/kvilib/net/kvi_netutils.cpp index f2c47215e..20160271c 100644 --- a/src/kvilib/net/kvi_netutils.cpp +++ b/src/kvilib/net/kvi_netutils.cpp @@ -26,9 +26,11 @@ // This effect is caused by the combination of broken CVS installation and // the ugly windows "text mode" files -#define __KVILIB__ #define _KVI_NETUTILS_CPP_ +#define NTDDI_VERSION NTDDI_WINXP +#define _WIN32_WINNT _WIN32_WINNT_WINXP + #include "kvi_netutils.h" #include "kvi_memmove.h" @@ -210,11 +212,6 @@ bool kvi_isValidStringIp(const char *szIp) #ifdef COMPILE_IPV6_SUPPORT #if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) -//#include <stdlib.h> -//#include <sys/socket.h> -//#include <arpa/inet.h>/ -//#include <errno.h> -//#include "dietfeatures.h" static unsigned int scan_ip6(const char *s,char ip[16]) { @@ -303,8 +300,6 @@ static unsigned int scan_ip6(const char *s,char ip[16]) return len; } -#ifndef COMPILE_ON_WINDOWS -// #include <Ws2tcpip.h> - already has it int inet_pton(int AF, const char *CP, void *BUF) { int len; if (AF==AF_INET) { @@ -319,12 +314,6 @@ int inet_pton(int AF, const char *CP, void *BUF) { } return 1; } -#endif //WIN2K - -//#include <sys/socket.h> -//#include <arpa/inet.h> - -//extern char *inet_ntoa_r(struct in_addr in,char* buf); static const unsigned char V4mappedprefix[12]={0,0,0,0,0,0,0,0,0,0,0xff,0xff}; diff --git a/src/kvilib/net/kvi_socket.cpp b/src/kvilib/net/kvi_socket.cpp index 198eaf1cf..2302d87e6 100644 --- a/src/kvilib/net/kvi_socket.cpp +++ b/src/kvilib/net/kvi_socket.cpp @@ -22,7 +22,6 @@ #define _KVI_SOCKET_CPP_ -#define __KVILIB__ #include "kvi_socket.h" #include "kvi_inttypes.h" diff --git a/src/kvilib/net/kvi_ssl.cpp b/src/kvilib/net/kvi_ssl.cpp index 234352434..043542f75 100644 --- a/src/kvilib/net/kvi_ssl.cpp +++ b/src/kvilib/net/kvi_ssl.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_ssl.h" @@ -318,7 +317,7 @@ bool KviSSL::initSocket(kvi_socket_t fd) if(!m_pSSL)return false; if(!SSL_set_fd(m_pSSL,fd))return false; return true; - + } static int cb(char *buf, int size, int rwflag, void *u) @@ -383,7 +382,7 @@ KviSSL::Result KviSSL::usePrivateKeyFile(const char * key,const char * pass) unsigned long KviSSL::getLastError(bool bPeek) { - return bPeek ? ERR_peek_error() : ERR_get_error(); + return bPeek ? ERR_peek_error() : ERR_get_error(); } bool KviSSL::getLastErrorString(KviStr &buffer,bool bPeek) @@ -647,7 +646,7 @@ void KviSSLCertificate::extractSignature() /* const char * KviSSLCertificate::verify() { - + } */ diff --git a/src/kvilib/net/kvi_url.cpp b/src/kvilib/net/kvi_url.cpp index 39e91a114..152d2645c 100644 --- a/src/kvilib/net/kvi_url.cpp +++ b/src/kvilib/net/kvi_url.cpp @@ -21,7 +21,6 @@ // -#define __KVILIB__ #include "kvi_url.h" @@ -49,7 +48,7 @@ KviUrl::KviUrl(const QString &szUrl) KviUrl::~KviUrl() { - + } void KviUrl::parse() @@ -65,7 +64,7 @@ void KviUrl::parse() KviStr u = m_szUrl; // proto - + kvi_u32_t uDefaultPort = 80; int i = u.findFirstIdx(":/"); @@ -76,7 +75,7 @@ void KviUrl::parse() u.cutLeft(i + 2); u.stripLeft('/'); u.trimmed(); - + // fix the default ports if(kvi_strEqualCI(m_szProtocol,"https"))uDefaultPort = 443; else if(kvi_strEqualCI(m_szProtocol,"ftp"))uDefaultPort = 21; @@ -85,7 +84,7 @@ void KviUrl::parse() u.stripLeft('/'); m_szProtocol = "http"; } - + m_uPort = uDefaultPort; // user and pass diff --git a/src/kvilib/system/kvi_env.cpp b/src/kvilib/system/kvi_env.cpp index 383c170fb..a893a9ad7 100644 --- a/src/kvilib/system/kvi_env.cpp +++ b/src/kvilib/system/kvi_env.cpp @@ -21,7 +21,6 @@ // Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // //============================================================================= -#define __KVILIB__ #define _KVI_ENV_CPP_ diff --git a/src/kvilib/system/kvi_locale.cpp b/src/kvilib/system/kvi_locale.cpp index 2c76e9750..318ebb0dd 100644 --- a/src/kvilib/system/kvi_locale.cpp +++ b/src/kvilib/system/kvi_locale.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ //#define _KVI_DEBUG_CHECK_RANGE_ @@ -55,7 +54,7 @@ static QTextCodec * g_pUtf8TextCodec = 0; ///////////////////////////////////////////////////////////////////////////////////////////////////// // -// The following code was extracted and adapted from gutf8.c +// The following code was extracted and adapted from gutf8.c // from the GNU GLIB2 package. // // gutf8.c - Operations on UTF-8 strings. @@ -114,7 +113,7 @@ fast_validate (const char *str) else { const gchar *last; - + last = p; if ((*(guchar *)p & 0xe0) == 0xc0) /* 110xxxxx */ { @@ -138,7 +137,7 @@ fast_validate (const char *str) val = *(guchar *)p & 0x07; } else goto error; - + p++; CONTINUATION_CHAR; TWO_REMAINING: @@ -146,19 +145,19 @@ fast_validate (const char *str) CONTINUATION_CHAR; p++; CONTINUATION_CHAR; - + if (val < min) goto error; - + if (!UNICODE_VALID(val)) goto error; } - + continue; error: return last; } } - + return p; } @@ -176,13 +175,13 @@ fast_validate_len (const char *str, gssize max_len) else { const gchar *last; - + last = p; if ((*(guchar *)p & 0xe0) == 0xc0) /* 110xxxxx */ { if (max_len >= 0 && max_len - (p - str) < 2) goto error; - + if ((*(guchar *)p & 0x1e) == 0) goto error; p++; @@ -195,7 +194,7 @@ fast_validate_len (const char *str, gssize max_len) { if (max_len >= 0 && max_len - (p - str) < 3) goto error; - + min = (1 << 11); val = *(guchar *)p & 0x0f; goto TWO_REMAINING; @@ -204,13 +203,13 @@ fast_validate_len (const char *str, gssize max_len) { if (max_len >= 0 && max_len - (p - str) < 4) goto error; - + min = (1 << 16); val = *(guchar *)p & 0x07; } else goto error; - + p++; CONTINUATION_CHAR; TWO_REMAINING: @@ -218,18 +217,18 @@ fast_validate_len (const char *str, gssize max_len) CONTINUATION_CHAR; p++; CONTINUATION_CHAR; - + if (val < min) goto error; if (!UNICODE_VALID(val)) goto error; } - + continue; - + error: return last; } } - + return p; } @@ -238,14 +237,14 @@ static bool g_utf8_validate (const char *str, const gchar **end) { const gchar *p; - + if (max_len < 0) p = fast_validate (str); else p = fast_validate_len (str, max_len); - + if (end) *end = p; - + if ((max_len >= 0 && p != str + max_len) || (max_len < 0 && *p != '\0')) return false; @@ -315,7 +314,7 @@ static KviPointerHashTable<const char *,KviSmartTextCodec> * g_pSmartCodecDict // // The following code was extracted and adapted from gettext.h and gettextP.h // from the GNU gettext package. -// +// // Internal header for GNU gettext internationalization functions. // Copyright (C) 1995, 1997 Free Software Foundation, Inc. // @@ -332,7 +331,7 @@ static KviPointerHashTable<const char *,KviSmartTextCodec> * g_pSmartCodecDict // You should have received a copy of the GNU Library General Public // License along with the GNU C Library; see the file COPYING.LIB. If not, // write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -// Boston, MA 02111-1307, USA. +// Boston, MA 02111-1307, USA. // ///////////////////////////////////////////////////////////////////////////////////////////////////// @@ -711,44 +710,44 @@ namespace KviLocale { "UTF-8 [ISO-8859-2]" , 1 , 1 , "I: 8-bit Unicode / Central European 1, O: 8-bit Unicode" }, { "UTF-8 [ISO-8859-3]" , 1 , 1 , "I: 8-bit Unicode / Central European 2, O: 8-bit Unicode" }, { "UTF-8 [ISO-8859-4]" , 1 , 1 , "I: 8-bit Unicode / Baltic, Standard, O: 8-bit Unicode" }, - + { "UTF-8 [ISO-8859-5]" , 1 , 1 , "I: 8-bit Unicode / Cyrillic, ISO, O: 8-bit Unicode" }, { "UTF-8 [ISO-8859-6]" , 1 , 1 , "I: 8-bit Unicode / Arabic, Standard, O: 8-bit Unicode" }, { "UTF-8 [ISO-8859-7]" , 1 , 1 , "I: 8-bit Unicode / Greek, O: 8-bit Unicode" }, { "UTF-8 [ISO-8859-8]" , 1 , 1 , "I: 8-bit Unicode / Hebrew, visually ordered, O: 8-bit Unicode" }, - + { "UTF-8 [ISO-8859-8-i]" , 1 , 1 , "I: 8-bit Unicode / Hebrew, logically ordered, O: 8-bit Unicode" }, { "UTF-8 [ISO-8859-9]" , 1 , 1 , "I: 8-bit Unicode / Turkish, Latin-5, O: 8-bit Unicode" }, { "UTF-8 [ISO-8859-15]" , 1 , 1 , "I: 8-bit Unicode / Western, Latin-1 + Euro, O: 8-bit Unicode" }, { "UTF-8 [KOI8-R]" , 1 , 1 , "I: 8-bit Unicode / Cyrillic, KOI, O: 8-bit Unicode" }, - + { "UTF-8 [KOI8-U]" , 1 , 1 , "I: 8-bit Unicode / Ukrainian, O: 8-bit Unicode" }, { "UTF-8 [CP-1250]" , 1 , 1 , "I: 8-bit Unicode / Central European 3, O: 8-bit Unicode" }, { "UTF-8 [CP-1251]" , 1 , 1 , "I: 8-bit Unicode / Cyrillic, Windows, O: 8-bit Unicode" }, { "UTF-8 [CP-1252]" , 1 , 1 , "I: 8-bit Unicode / Western, CP, O: 8-bit Unicode" }, - + { "UTF-8 [CP-1253]" , 1 , 1 , "I: 8-bit Unicode / Greek, CP, O: 8-bit Unicode" }, { "UTF-8 [CP-1256]" , 1 , 1 , "I: 8-bit Unicode / Arabic, CP, O: 8-bit Unicode" }, { "UTF-8 [CP-1257]" , 1 , 1 , "I: 8-bit Unicode / Baltic, CP, O: 8-bit Unicode" }, { "UTF-8 [CP-1255]" , 1 , 1 , "I: 8-bit Unicode / Hebrew, CP, O: 8-bit Unicode" }, - + { "UTF-8 [CP-1254]" , 1 , 1 , "I: 8-bit Unicode / Turkish, CP, O: 8-bit Unicode" }, { "UTF-8 [TIS-620]" , 1 , 1 , "I: 8-bit Unicode / Thai, O: 8-bit Unicode" }, #ifndef QT_NO_BIG_CODECS { "UTF-8 [Big5]" , 1 , 1 , "I: 8-bit Unicode / Chinese Traditional, O: 8-bit Unicode" }, { "UTF-8 [Big5-HKSCS]" , 1 , 1 , "I: 8-bit Unicode / Chinese Traditional, Hong Kong, O: 8-bit Unicode" }, - + { "UTF-8 [GB18030]" , 1 , 1 , "I: 8-bit Unicode / Chinese Simplified, O: 8-bit Unicode" }, { "UTF-8 [JIS7]" , 1 , 1 , "I: 8-bit Unicode / Japanese (JIS7), O: 8-bit Unicode" }, { "UTF-8 [Shift-JIS]" , 1 , 1 , "I: 8-bit Unicode / Japanese (Shift-JIS), O: Japanese (Shift-JIS)" }, { "UTF-8 [EUC-JP]" , 1 , 1 , "I: 8-bit Unicode / Japanese (EUC-JP), O: Japanese (EUC-JP)" }, - + { "UTF-8 [EUC-KR]" , 1 , 1 , "I: 8-bit Unicode / Korean, O: 8-bit Unicode" }, { "UTF-8 [TSCII]" , 1 , 1 , "I: 8-bit Unicode / Tamil, O: 8-bit Unicode" }, #endif { "UTF-8 [ISO-8859-10]" , 1 , 1 , "I: 8-bit Unicode / ISO-8859-10, O: 8-bit Unicode" }, { "UTF-8 [ISO-8859-13]" , 1 , 1 , "I: 8-bit Unicode / ISO-8859-13, O: 8-bit Unicode" }, - + { "UTF-8 [ISO-8859-14]" , 1 , 1 , "I: 8-bit Unicode / ISO-8859-14, O: 8-bit Unicode" }, { "UTF-8 [IBM-850]" , 1 , 1 , "I: 8-bit Unicode / IBM-850, O: 8-bit Unicode" }, { "UTF-8 [IBM-866]" , 1 , 1 , "I: 8-bit Unicode / IBM-866, O: 8-bit Unicode" }, @@ -756,7 +755,7 @@ namespace KviLocale { 0 , 0 , 0 , 0 } }; - + EncodingDescription * encodingDescription(int iIdx) { if(iIdx > NUM_ENCODINGS)return &(supported_encodings[NUM_ENCODINGS]); @@ -772,8 +771,8 @@ namespace KviLocale // composite codec: either UTF-8 [child codec] or child codec [UTF-8] KviSmartTextCodec * c = g_pSmartCodecDict->find(szName); if(c)return c; - - + + if(kvi_strEqualCIN("UTF-8 [",szName,7)) { szTmp.replaceAll("UTF-8 [",""); diff --git a/src/kvilib/system/kvi_thread.cpp b/src/kvilib/system/kvi_thread.cpp index 13a320ffb..7c392623e 100644 --- a/src/kvilib/system/kvi_thread.cpp +++ b/src/kvilib/system/kvi_thread.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #ifndef _GNU_SOURCE @@ -88,17 +87,17 @@ static void kvi_threadIgnoreSigalarm() struct sigaction ignr_act; ignr_act.sa_handler = SIG_IGN; sigemptyset(&ignr_act.sa_mask); - + #ifdef SA_NOMASK ignr_act.sa_flags = SA_NOMASK; #else ignr_act.sa_flags = 0; #endif - + #ifdef SA_RESTART ignr_act.sa_flags |= SA_RESTART; #endif - + if(sigaction(SIGALRM,&ignr_act,0) == -1)debug("Failed to set SIG_IGN for SIGALRM."); #endif #endif @@ -133,7 +132,7 @@ static void kvi_threadCatchSigpipe() act.sa_flags |= SA_RESTART; #endif - if(sigaction(SIGPIPE,&act,0L) == -1)debug("Failed to set the handler for SIGPIPE."); + if(sigaction(SIGPIPE,&act,0L) == -1)debug("Failed to set the handler for SIGPIPE."); #endif } diff --git a/src/kvilib/system/kvi_time.cpp b/src/kvilib/system/kvi_time.cpp index 83a8dfa70..4c6af9f69 100644 --- a/src/kvilib/system/kvi_time.cpp +++ b/src/kvilib/system/kvi_time.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_time.h" @@ -92,7 +91,7 @@ namespace KviTimeUtils *uM = uSecs / 60; *uS = uSecs % 60; } - + QString formatTimeInterval(unsigned int uSeconds,int iFlags) { unsigned int d,h,m,s; diff --git a/src/kvilib/tal/kvi_tal_application.cpp b/src/kvilib/tal/kvi_tal_application.cpp index a86590eb2..b698eb3ce 100644 --- a/src/kvilib/tal/kvi_tal_application.cpp +++ b/src/kvilib/tal/kvi_tal_application.cpp @@ -20,7 +20,6 @@ // Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // -#define __KVILIB__ #include "kvi_tal_application.h" diff --git a/src/kvilib/tal/kvi_tal_filedialog.cpp b/src/kvilib/tal/kvi_tal_filedialog.cpp index 62fe2005b..fcc1f27e0 100644 --- a/src/kvilib/tal/kvi_tal_filedialog.cpp +++ b/src/kvilib/tal/kvi_tal_filedialog.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_tal_filedialog.h" diff --git a/src/kvilib/tal/kvi_tal_groupbox.cpp b/src/kvilib/tal/kvi_tal_groupbox.cpp index 62a29c0df..65d91e5a2 100644 --- a/src/kvilib/tal/kvi_tal_groupbox.cpp +++ b/src/kvilib/tal/kvi_tal_groupbox.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_tal_groupbox.h" #include <QChildEvent> @@ -77,7 +76,7 @@ void KviTalGroupBox::addSpace(int space) if (m_pLayout){ if (mOrientation==Qt::Vertical) ((QHBoxLayout*)m_pLayout)->addSpacing(space); - else + else ((QVBoxLayout*)m_pLayout)->addSpacing(space); } } diff --git a/src/kvilib/tal/kvi_tal_hbox.cpp b/src/kvilib/tal/kvi_tal_hbox.cpp index d156c658d..d75b7e672 100644 --- a/src/kvilib/tal/kvi_tal_hbox.cpp +++ b/src/kvilib/tal/kvi_tal_hbox.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_tal_hbox.h" #include <QChildEvent> diff --git a/src/kvilib/tal/kvi_tal_iconview.cpp b/src/kvilib/tal/kvi_tal_iconview.cpp index 4d4a63e6d..80e9c32b1 100644 --- a/src/kvilib/tal/kvi_tal_iconview.cpp +++ b/src/kvilib/tal/kvi_tal_iconview.cpp @@ -22,7 +22,6 @@ //
//=============================================================================
-#define __KVILIB__
#include "kvi_tal_iconview.h"
#include <QTableWidget>
diff --git a/src/kvilib/tal/kvi_tal_itemdelegates.cpp b/src/kvilib/tal/kvi_tal_itemdelegates.cpp index cf338eab0..fe9ab9dfa 100644 --- a/src/kvilib/tal/kvi_tal_itemdelegates.cpp +++ b/src/kvilib/tal/kvi_tal_itemdelegates.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_tal_itemdelegates.h" #include <QListWidget> #include <QPainter> @@ -66,7 +65,7 @@ void KviTalIconAndRichTextItemDelegate::paint( QPainter * painter, const QStyleO painter->translate(option.rect.x()+afterIcon,option.rect.y()+LVI_BORDER); doc.setTextWidth(option.rect.width()-10); QRect cliprect=QRect(QPoint(0,0),QSize(option.rect.width()-afterIcon,option.rect.height()-(LVI_BORDER*2)-4)); - doc.drawContents(painter, cliprect); + doc.drawContents(painter, cliprect); painter->restore(); } @@ -77,7 +76,7 @@ QSize KviTalIconAndRichTextItemDelegate::sizeHint( const QStyleOptionViewItem & doc.setHtml( text ); int height=doc.documentLayout()->documentSize().height(); if (height<(LVI_ICON_SIZE+(2 * LVI_BORDER))) height=LVI_ICON_SIZE; - return QSize(((QListWidget*)parent())->viewport()->size().width(), height + (2 * LVI_BORDER)); + return QSize(((QListWidget*)parent())->viewport()->size().width(), height + (2 * LVI_BORDER)); } diff --git a/src/kvilib/tal/kvi_tal_listbox.cpp b/src/kvilib/tal/kvi_tal_listbox.cpp index 67c42a2a1..251d10e23 100644 --- a/src/kvilib/tal/kvi_tal_listbox.cpp +++ b/src/kvilib/tal/kvi_tal_listbox.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_tal_listbox.h" #include <QPainter> diff --git a/src/kvilib/tal/kvi_tal_listview.cpp b/src/kvilib/tal/kvi_tal_listview.cpp index ab522388a..3809e887f 100644 --- a/src/kvilib/tal/kvi_tal_listview.cpp +++ b/src/kvilib/tal/kvi_tal_listview.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_tal_listview.h" #include "kvi_pointerhashtable.h" @@ -392,7 +391,7 @@ void KviTalCheckListItem::setState(ToggleState s, bool update, bool store) parent() && parent()->rtti() == 1 && ((KviTalCheckListItem*)parent())->type() == CheckBoxController) ((KviTalCheckListItem*)parent())->updateController(update, store); - + updateController(update, store); } else { // if there are no children we simply set the CheckBoxController and update its parent @@ -736,7 +735,7 @@ void KviTalCheckListItem::paintCell(QPainter * p, const QColorGroup & cg, int co y = ((height() - boxsize) / 2) + marg; else y = (fm.height() + 2 + marg - boxsize) / 2; - + QStyleOptionQ3ListView opt = getStyleOption(lv, this); opt.rect.setRect(x, y, boxsize, fm.height() + 2 + marg); opt.palette = cg; diff --git a/src/kvilib/tal/kvi_tal_listwidget.cpp b/src/kvilib/tal/kvi_tal_listwidget.cpp index 9cab44d1c..9f9191f19 100644 --- a/src/kvilib/tal/kvi_tal_listwidget.cpp +++ b/src/kvilib/tal/kvi_tal_listwidget.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_tal_listwidget.h" #include "kvi_tal_itemdelegates.h" @@ -38,8 +37,8 @@ KviTalListWidget::KviTalListWidget(QWidget * pParent,QString name,Qt::WFlags f) } bool KviTalListWidget::event(QEvent * e) { - - if (e->type() == QEvent::ToolTip)
+ + if (e->type() == QEvent::ToolTip)
{
QHelpEvent *helpEvent = static_cast<QHelpEvent *>(e);
const QPoint &p=helpEvent->pos();
diff --git a/src/kvilib/tal/kvi_tal_mainwindow.cpp b/src/kvilib/tal/kvi_tal_mainwindow.cpp index 3b73bdd71..8041e0ca7 100644 --- a/src/kvilib/tal/kvi_tal_mainwindow.cpp +++ b/src/kvilib/tal/kvi_tal_mainwindow.cpp @@ -20,7 +20,6 @@ // Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // -#define __KVILIB__ #include "kvi_tal_mainwindow.h" diff --git a/src/kvilib/tal/kvi_tal_menubar.cpp b/src/kvilib/tal/kvi_tal_menubar.cpp index 08d0b4c9e..4ed91853e 100644 --- a/src/kvilib/tal/kvi_tal_menubar.cpp +++ b/src/kvilib/tal/kvi_tal_menubar.cpp @@ -20,7 +20,6 @@ // Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // -#define __KVILIB__ #include "kvi_tal_menubar.h" diff --git a/src/kvilib/tal/kvi_tal_popupmenu.cpp b/src/kvilib/tal/kvi_tal_popupmenu.cpp index 5d5b1767c..cc438a453 100644 --- a/src/kvilib/tal/kvi_tal_popupmenu.cpp +++ b/src/kvilib/tal/kvi_tal_popupmenu.cpp @@ -22,7 +22,6 @@ //
//=============================================================================
-#define __KVILIB__
#include "kvi_tal_popupmenu.h"
#include <QMenu>
@@ -84,10 +83,10 @@ int KviTalPopupMenu::insertItem(const QString &szText,const QObject * pReceiver, // create a compatible slot
signalMapper[action] = new QSignalMapper();
signalMapper[action]->setMapping(action, identifier);
-
+
connect(action, SIGNAL(triggered()), signalMapper[action], SLOT(map()));
connect(signalMapper[action], SIGNAL(mapped(int)), pReceiver, szSlot);
-
+
actionsDict[identifier++]=action;
return identifier-1;
}
@@ -95,14 +94,14 @@ int KviTalPopupMenu::insertItem(const QString &szText,const QObject * pReceiver, int KviTalPopupMenu::insertItem(const QPixmap &pix,const QString &szText,const QObject * pReceiver,const char * szSlot)
{
QAction * action = addAction(pix, szText);
-
+
// create a compatible slot
signalMapper[action] = new QSignalMapper();
signalMapper[action]->setMapping(action, identifier);
-
+
connect(action, SIGNAL(triggered()), signalMapper[action], SLOT(map()));
connect(signalMapper[action], SIGNAL(mapped(int)), pReceiver, szSlot);
-
+
actionsDict.insert(identifier, action);
actionsDict[identifier++] = action;
return identifier-1;
@@ -143,14 +142,14 @@ void KviTalPopupMenu::setItemChecked(int id,bool check) void KviTalPopupMenu::setItemParameter(int id, int param)
{
QAction * action = actionsDict.value(id);
-
+
// take care of the slot
if (signalMapper[action])
{
signalMapper[action]->removeMappings(action);
signalMapper[action]->setMapping(action, param);
}
-
+
QVariant par(param);
if (action) action->setData(par);
}
@@ -192,11 +191,11 @@ int KviTalPopupMenu::insertSeparator() void KviTalPopupMenu::slottriggered(QAction * a)
{
if (signalMapper[a]) return; // When signalmapper is used we don't need this event
-
+
int i = actionsDict.key(a, -1); // See if action exists and get ID
if (i != -1)
{
- emit activated(i);
+ emit activated(i);
}
return;
diff --git a/src/kvilib/tal/kvi_tal_scrollview.cpp b/src/kvilib/tal/kvi_tal_scrollview.cpp index 33564e9e2..b207a96d3 100644 --- a/src/kvilib/tal/kvi_tal_scrollview.cpp +++ b/src/kvilib/tal/kvi_tal_scrollview.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_tal_scrollview.h" int KviTalScrollView::childX(QWidget * child) diff --git a/src/kvilib/tal/kvi_tal_tabdialog.cpp b/src/kvilib/tal/kvi_tal_tabdialog.cpp index 507016fee..c75bdba67 100644 --- a/src/kvilib/tal/kvi_tal_tabdialog.cpp +++ b/src/kvilib/tal/kvi_tal_tabdialog.cpp @@ -23,7 +23,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_tal_tabdialog.h" #include <QDialog> diff --git a/src/kvilib/tal/kvi_tal_tablewidget.cpp b/src/kvilib/tal/kvi_tal_tablewidget.cpp index 80fe4d59e..e682ea00d 100644 --- a/src/kvilib/tal/kvi_tal_tablewidget.cpp +++ b/src/kvilib/tal/kvi_tal_tablewidget.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_tal_tablewidget.h" /* diff --git a/src/kvilib/tal/kvi_tal_textedit.cpp b/src/kvilib/tal/kvi_tal_textedit.cpp index 4c241728e..8e25e4049 100644 --- a/src/kvilib/tal/kvi_tal_textedit.cpp +++ b/src/kvilib/tal/kvi_tal_textedit.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_tal_textedit.h" diff --git a/src/kvilib/tal/kvi_tal_toolbar.cpp b/src/kvilib/tal/kvi_tal_toolbar.cpp index e88b4cda9..25b91c311 100644 --- a/src/kvilib/tal/kvi_tal_toolbar.cpp +++ b/src/kvilib/tal/kvi_tal_toolbar.cpp @@ -20,7 +20,6 @@ // Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // -#define __KVILIB__ #include "kvi_tal_toolbar.h" diff --git a/src/kvilib/tal/kvi_tal_tooltip.cpp b/src/kvilib/tal/kvi_tal_tooltip.cpp index ae4dee4a3..183fdc55c 100644 --- a/src/kvilib/tal/kvi_tal_tooltip.cpp +++ b/src/kvilib/tal/kvi_tal_tooltip.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_tal_tooltip.h" #include <QEvent> @@ -90,7 +89,7 @@ void KviTalToolTip::add(QWidget * widget,const QString & text) void KviTalToolTip::remove(QWidget * widget) { - //QToolTip::remove(widget); + //QToolTip::remove(widget); } void KviTalToolTip::tip(const QRect & rect,const QString & text) diff --git a/src/kvilib/tal/kvi_tal_treewidget.cpp b/src/kvilib/tal/kvi_tal_treewidget.cpp index 4c1a69a5c..bb946e733 100644 --- a/src/kvilib/tal/kvi_tal_treewidget.cpp +++ b/src/kvilib/tal/kvi_tal_treewidget.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_tal_treewidget.h" #include "kvi_pointerhashtable.h" diff --git a/src/kvilib/tal/kvi_tal_vbox.cpp b/src/kvilib/tal/kvi_tal_vbox.cpp index 0621a1980..0c886e30a 100644 --- a/src/kvilib/tal/kvi_tal_vbox.cpp +++ b/src/kvilib/tal/kvi_tal_vbox.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_tal_vbox.h" #include <QChildEvent> diff --git a/src/kvilib/tal/kvi_tal_widgetstack.cpp b/src/kvilib/tal/kvi_tal_widgetstack.cpp index a453a53c5..25d79f446 100644 --- a/src/kvilib/tal/kvi_tal_widgetstack.cpp +++ b/src/kvilib/tal/kvi_tal_widgetstack.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_tal_widgetstack.h" #ifndef COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/kvilib/tal/kvi_tal_wizard.cpp b/src/kvilib/tal/kvi_tal_wizard.cpp index bb0d9455f..6200f7883 100644 --- a/src/kvilib/tal/kvi_tal_wizard.cpp +++ b/src/kvilib/tal/kvi_tal_wizard.cpp @@ -22,7 +22,6 @@ // //============================================================================= -#define __KVILIB__ #include "kvi_tal_wizard.h" #include "kvi_tal_hbox.h" #include "kvi_pointerlist.h" @@ -126,7 +125,7 @@ public: } return NULL; } - + int reindexPages() { int iEnabledCount = 0; @@ -240,7 +239,7 @@ KviTalWizard::KviTalWizard(QWidget * pParent) this, SLOT(finishButtonClicked()) ); - + m_p->pLayout->setMargin(8); m_p->pLayout->setSpacing(4); m_p->pLayout->setRowStretch(2,1); @@ -354,7 +353,7 @@ void KviTalWizard::setCurrentPage(KviTalWizardPageData * pData) (clrWin.green() + clrTxt.green()) / 2, (clrWin.blue() + clrTxt.blue()) / 2 ); - + szSteps = "<nobr><font color=\""; szSteps += clrMid.name(); szSteps += "\"><b>["; @@ -527,7 +526,7 @@ QPushButton * KviTalWizard::backButton() return m_p->pBackButton; } -#ifdef COMPILE_ON_WINDOWS +#ifdef COMPILE_ON_WINDOWS #ifndef COMPILE_USE_STANDALONE_MOC_SOURCES #include "kvi_tal_wizard.moc" #endif //!COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/kvirc/kernel/kvi_iconmanager.cpp b/src/kvirc/kernel/kvi_iconmanager.cpp index 4de90fdd0..2e2a37ddc 100644 --- a/src/kvirc/kernel/kvi_iconmanager.cpp +++ b/src/kvirc/kernel/kvi_iconmanager.cpp @@ -481,11 +481,11 @@ KviIconManager::KviIconManager() g_pApp->findImage(buffer,KVI_ACTIVITYMETER_IMAGE_NAME); g_pActivityMeterPixmap = new QPixmap(buffer.ptr()); - + m_pIconNames = 0; - + // TEMP - + /* for(i=0;i<KVI_NUM_SMALL_ICONS;i++) { @@ -532,7 +532,7 @@ int KviIconManager::getSmallIconIdFromName(const QString &szName) { m_pIconNames = new KviPointerHashTable<QString,int>(257,false); m_pIconNames->setAutoDelete(true); - + for(int i=0;i<KVI_NUM_SMALL_ICONS;i++) { int * pInt = new int; @@ -666,7 +666,7 @@ KviCachedPixmap * KviIconManager::getPixmapWithCacheScaleOnLoad(const QString &s scaleH = iMaxHeight; scaleW = (scaleH * pix->width()) / pix->height(); } - + QImage img = pix->toImage(); *pix = QPixmap::fromImage(img.scaled(scaleW,scaleH,Qt::IgnoreAspectRatio,Qt::SmoothTransformation)); } @@ -787,7 +787,7 @@ KviAvatar * KviIconManager::getAvatar(const QString &szLocalPath,const QString & urlToCachedFileName(szP); } else { szN = KviFileUtils::extractFileName(szName); - szP = szName; + g_pApp->getLocalKvircDirectory(szP,KviApp::Avatars,szName); } } else if(szName.isEmpty()) { @@ -800,12 +800,30 @@ KviAvatar * KviIconManager::getAvatar(const QString &szLocalPath,const QString & } // avatars bigger than 1024x768 just sux: they can't be seen on tooltips anyway - KviCachedPixmap * p = KVI_OPTION_BOOL(KviOption_boolScaleAvatarsOnLoad) ? getPixmapWithCacheScaleOnLoad(szP, - KVI_OPTION_UINT(KviOption_uintScaleAvatarsOnLoadWidth) - ,KVI_OPTION_UINT(KviOption_uintScaleAvatarsOnLoadHeight)) : getPixmapWithCache(szP); - if(!p)return 0; + //KviCachedPixmap * p = KVI_OPTION_BOOL(KviOption_boolScaleAvatarsOnLoad) ? getPixmapWithCacheScaleOnLoad(szP, + // KVI_OPTION_UINT(KviOption_uintScaleAvatarsOnLoadWidth) + // ,KVI_OPTION_UINT(KviOption_uintScaleAvatarsOnLoadHeight)) : getPixmapWithCache(szP); + //if(!p)return 0; + + + + if(KviFileUtils::fileExists(szP)) + { + if(KVI_OPTION_BOOL(KviOption_boolScaleAvatarsOnLoad)) + { + return new KviAvatar(szP,szN, + QSize( + KVI_OPTION_UINT(KviOption_uintScaleAvatarsOnLoadWidth), + KVI_OPTION_UINT(KviOption_uintScaleAvatarsOnLoadHeight) + ) + ); + } else { + return new KviAvatar(szP,szN); + } + } else { + return 0; + } - return new KviAvatar(p->path(),szN,new QPixmap(*(p->pixmap()))); } void KviIconManager::clearCache() @@ -828,11 +846,11 @@ QPixmap * KviIconManager::loadSmallIcon(int idx) { if(idx >= KVI_NUM_SMALL_ICONS)return 0; if(idx < 0)return 0; - + QString szPath; QString buffer; KviQString::sprintf(szPath,KVI_SMALLICONS_PREFIX "%s.png",g_szIconNames[idx]); - + g_pApp->findSmallIcon(buffer,szPath); m_smallIcons[idx] = new QPixmap(buffer); @@ -855,7 +873,7 @@ void KviIconManager::cacheCleanup() while(it.current()) { kvi_time_t curTime = kvi_unixTime(); - + if((((unsigned int)it.current()->timestamp) - ((unsigned int)curTime)) > 120) { // unused since 2 minutes diff --git a/src/kvirc/kernel/kvi_options.cpp b/src/kvirc/kernel/kvi_options.cpp index 16b848fb2..e216aa156 100644 --- a/src/kvirc/kernel/kvi_options.cpp +++ b/src/kvirc/kernel/kvi_options.cpp @@ -307,7 +307,8 @@ KviBoolOption g_boolOptionsTable[KVI_NUM_BOOL_OPTIONS]= BOOL_OPTION("DisableNotifierFadein",false,KviOption_sectFlagFrame), BOOL_OPTION("UseAntiAliasing",true,KviOption_sectFlagGui | KviOption_resetUpdateGui), BOOL_OPTION("PickRandomIpAddressForRoundRobinServers",true,KviOption_sectFlagConnection), - BOOL_OPTION("PrependAvatarInfoToRealname",true,KviOption_sectFlagConnection) + BOOL_OPTION("PrependAvatarInfoToRealname",true,KviOption_sectFlagConnection), + BOOL_OPTION("EnableAnimatedAvatars",true,KviOption_sectFlagGui | KviOption_resetUpdateGui) }; #define STRING_OPTION(_txt,_val,_flags) KviStringOption(KVI_STRING_OPTIONS_PREFIX _txt,_val,_flags) diff --git a/src/kvirc/kernel/kvi_options.h b/src/kvirc/kernel/kvi_options.h index 6a7193631..70107b606 100644 --- a/src/kvirc/kernel/kvi_options.h +++ b/src/kvirc/kernel/kvi_options.h @@ -315,8 +315,9 @@ DECLARE_OPTION_STRUCT(KviStringListOption,QStringList) #define KviOption_boolUseAntiAliasing 221 /* qt4 only! */ #define KviOption_boolPickRandomIpAddressForRoundRobinServers 222 #define KviOption_boolPrependAvatarInfoToRealname 223 +#define KviOption_boolEnableAnimatedAvatars 224 -#define KVI_NUM_BOOL_OPTIONS 224 +#define KVI_NUM_BOOL_OPTIONS 225 diff --git a/src/kvirc/ui/kvi_console.cpp b/src/kvirc/ui/kvi_console.cpp index a636371d4..1687a8231 100644 --- a/src/kvirc/ui/kvi_console.cpp +++ b/src/kvirc/ui/kvi_console.cpp @@ -340,7 +340,7 @@ void KviConsole::getUserTipText(const QString &nick,KviIrcUserEntry *e,QString & if(e->avatar()) { - buffer += QString("<tr><td><center><img src=\"%1\" width=\"%2\"></center></td></tr>").arg(e->avatar()->localPath()).arg(e->avatar()->pixmap()->width()); + buffer += QString("<tr><td><center><img src=\"%1\" width=\"%2\"></center></td></tr>").arg(e->avatar()->localPath()).arg(e->avatar()->size().width()); } if(e->hasRealName()) @@ -1028,7 +1028,7 @@ KviAvatar * KviConsole::defaultAvatarFromOptions() if(!avatar)return 0; if(avatar->isNull())return 0; if(KVI_OPTION_STRING(KviOption_stringMyAvatar).isEmpty())return 0; - return new KviAvatar(KVI_OPTION_PIXMAP(KviOption_pixmapMyAvatar).path(),KVI_OPTION_STRING(KviOption_stringMyAvatar),new QPixmap(*avatar)); + return new KviAvatar(KVI_OPTION_PIXMAP(KviOption_pixmapMyAvatar).path(),KVI_OPTION_STRING(KviOption_stringMyAvatar)); } KviAvatar * KviConsole::currentAvatar() diff --git a/src/kvirc/ui/kvi_userlistview.cpp b/src/kvirc/ui/kvi_userlistview.cpp index e8ffe00df..b24f8c159 100644 --- a/src/kvirc/ui/kvi_userlistview.cpp +++ b/src/kvirc/ui/kvi_userlistview.cpp @@ -92,21 +92,91 @@ void KviUserListToolTip::maybeTip(const QPoint &pnt) KviUserListEntry::KviUserListEntry(KviUserListView * parent,const QString &nick, KviIrcUserEntry * e,short int iFlags,bool bJoinTimeUnknown) { - m_pListView = parent; - m_szNick = nick; - m_pGlobalData = e; - m_iFlags = iFlags; - m_lastActionTime = (kvi_time_t)0; - m_joinTime = bJoinTimeUnknown ? (kvi_time_t)0 : kvi_unixTime(); - m_iTemperature = bJoinTimeUnknown ? 0 : KVI_USERACTION_JOIN; + m_pListView = parent; + m_szNick = nick; + m_pGlobalData = e; + m_iFlags = iFlags; + m_lastActionTime = (kvi_time_t)0; + m_joinTime = bJoinTimeUnknown ? (kvi_time_t)0 : kvi_unixTime(); + m_iTemperature = bJoinTimeUnknown ? 0 : KVI_USERACTION_JOIN; + + m_bSelected = false; + m_pConnectedAnimation = 0; + - m_bSelected = false; - recalcSize(); + updateAvatarData(); } KviUserListEntry::~KviUserListEntry() { + if(m_pConnectedAnimation) + { + m_pConnectedAnimation->disconnect(SIGNAL(frameChanged() ), + m_pListView,SLOT(animatedAvatarUpdated())); + } +} + +void KviUserListEntry::resetAvatarConnection() +{ + m_pConnectedAnimation = 0; +} + +void KviUserListEntry::updateAvatarData() +{ + KviAnimatedPixmap* pOldMovie = m_pConnectedAnimation; + + m_pConnectedAnimation = 0; + + KviAvatar * av = m_pGlobalData->avatar(); + + if(!KVI_OPTION_BOOL(KviOption_boolDisableAvatars)) + { + if(av) + { + if( KVI_OPTION_BOOL(KviOption_boolScaleAvatars) && + ( + !KVI_OPTION_BOOL(KviOption_boolDoNotStretchAvatars) || + (av->size().width() > KVI_OPTION_UINT(KviOption_uintAvatarScaleWidth)) || + (av->size().height() > KVI_OPTION_UINT(KviOption_uintAvatarScaleHeight)) + ) + ) + { + m_pConnectedAnimation = av->forSize( + KVI_OPTION_UINT(KviOption_uintAvatarScaleWidth), + KVI_OPTION_UINT(KviOption_uintAvatarScaleHeight) + ); + } + else + { + m_pConnectedAnimation = av->animatedPixmap(); + } + } + } + + if(m_pConnectedAnimation!=pOldMovie) + { + if(KVI_OPTION_BOOL(KviOption_boolEnableAnimatedAvatars)) + { + m_pConnectedAnimation->start(); + } else { + m_pConnectedAnimation->stop(); + } + m_pListView->connect( + m_pConnectedAnimation,SIGNAL(frameChanged() ), + m_pListView,SLOT(animatedAvatarUpdated())); + + /* + The old one is deleted. + So it is disconnected automagically... + if(pOldMovie) + { + m_pListView->disconnect( + pOldMovie,SIGNAL(frameChanged()), + m_pListView,SLOT(animatedAvatarUpdated()) + ); + }*/ + } } bool KviUserListEntry::color(QColor& color) @@ -130,7 +200,7 @@ bool KviUserListEntry::color(QColor& color) color = KVI_OPTION_COLOR(KviOption_colorUserListViewOwnForeground); return true; } - } + } if(m_iFlags == 0) { color=KVI_OPTION_COLOR(KviOption_colorUserListViewNormalForeground); @@ -152,7 +222,7 @@ void KviUserListEntry::recalcSize() KviAvatar * av = m_pGlobalData->avatar(); m_iHeight = m_pListView->m_iFontHeight; if(KVI_OPTION_BOOL(KviOption_boolShowUserChannelIcons) && (m_iHeight < 20))m_iHeight = 20; - + if(!KVI_OPTION_BOOL(KviOption_boolDisableAvatars))//G&N 2005 { if(av) @@ -160,18 +230,22 @@ void KviUserListEntry::recalcSize() if( KVI_OPTION_BOOL(KviOption_boolScaleAvatars) && ( !KVI_OPTION_BOOL(KviOption_boolDoNotStretchAvatars) || - (av->pixmap()->width() > KVI_OPTION_UINT(KviOption_uintAvatarScaleWidth)) || - (av->pixmap()->height() > KVI_OPTION_UINT(KviOption_uintAvatarScaleHeight)) + (av->size().width() > KVI_OPTION_UINT(KviOption_uintAvatarScaleWidth)) || + (av->size().height() > KVI_OPTION_UINT(KviOption_uintAvatarScaleHeight)) ) ) { - QPixmap * pix = av->scaledPixmap(KVI_OPTION_UINT(KviOption_uintAvatarScaleWidth), KVI_OPTION_UINT(KviOption_uintAvatarScaleHeight)); - - m_iHeight += pix->height(); + //don't worry about resize action + //it has to be done anyway on painting + //and result will be cached. + m_iHeight += av->forSize( + KVI_OPTION_UINT(KviOption_uintAvatarScaleWidth), + KVI_OPTION_UINT(KviOption_uintAvatarScaleHeight) + )->size().height(); } else { - m_iHeight += av->pixmap()->height(); + m_iHeight += av->size().height(); } } } @@ -280,11 +354,11 @@ void KviUserListView::updateScrollBarRange() void KviUserListView::applyOptions() { -/* if(!KVI_OPTION_BOOL(KviOption_boolDisableUserListLabel)){ +/* if(!KVI_OPTION_BOOL(KviOption_boolDisableUserListLabel)){ m_pUsersLabel->hide(); m_pViewArea->setGeometry(0,0,width(),height()); } - if(KVI_OPTION_BOOL(KviOption_boolDisableUserListLabel)){ + if(KVI_OPTION_BOOL(KviOption_boolDisableUserListLabel)){ m_pUsersLabel->show(); updateUsersLabel(); }*/ @@ -295,6 +369,15 @@ void KviUserListView::applyOptions() m_iTotalHeight = 0; while(e) { + if(e->m_pConnectedAnimation) + { + if(KVI_OPTION_BOOL(KviOption_boolEnableAnimatedAvatars)) + { + e->m_pConnectedAnimation->start(); + } else { + e->m_pConnectedAnimation->stop(); + } + } e->recalcSize(); m_iTotalHeight += e->m_iHeight; e = e->m_pNext; @@ -336,6 +419,32 @@ void KviUserListView::setMaskEntries(char type, int num) updateUsersLabel(); } +void KviUserListView::animatedAvatarUpdated() +{ + //update(); + if(!m_pTopItem)return; + if(KVI_OPTION_BOOL(KviOption_boolDisableAvatars)) return; + QRect rct; + int curTop = KVI_USERLIST_BORDER_WIDTH - m_pViewArea->m_iTopItemOffset; + KviUserListEntry * e = m_pTopItem; + int curBottom = 0; + while(e && (curTop <= m_pViewArea->height())) + { + curBottom = curTop + e->m_iHeight; + if(e->m_pConnectedAnimation==sender()) + { + rct.setX(0); + rct.setY(curTop); + rct.setWidth(m_pViewArea->width()); + rct.setHeight(e->m_iHeight); + + m_pViewArea->update(rct); + } + curTop = curBottom; + e = e->m_pNext; + } +} + void KviUserListView::completeNickBashLike(const QString &begin,KviPointerList<QString> *l,bool bAppendMask) { KviUserListEntry * entry = m_pHeadItem; @@ -487,7 +596,7 @@ void KviUserListView::insertUserEntry(const QString &nick,KviUserListEntry * e) if(entry == m_pTopItem)bGotTopItem = true; entry = entry->m_pNext; } - + // is operator ? if(!(e->m_iFlags & KVI_USERFLAG_OP)) { @@ -498,7 +607,7 @@ void KviUserListView::insertUserEntry(const QString &nick,KviUserListEntry * e) if(entry == m_pTopItem)bGotTopItem = true; entry = entry->m_pNext; } - + // is half oped ? if(!(e->m_iFlags & KVI_USERFLAG_HALFOP)) { @@ -508,7 +617,7 @@ void KviUserListView::insertUserEntry(const QString &nick,KviUserListEntry * e) if(entry == m_pTopItem)bGotTopItem = true; entry = entry->m_pNext; } - + // is voiced ? if(!(e->m_iFlags & KVI_USERFLAG_VOICE)) { @@ -518,7 +627,7 @@ void KviUserListView::insertUserEntry(const QString &nick,KviUserListEntry * e) if(entry == m_pTopItem)bGotTopItem = true; entry = entry->m_pNext; } - + // is userop'd? if(!(e->m_iFlags & KVI_USERFLAG_USEROP)) { @@ -534,7 +643,7 @@ void KviUserListView::insertUserEntry(const QString &nick,KviUserListEntry * e) } // else it is op , chan admins are skipped } // else it is chan admin , chan owners are skipped } // else it is chan owner, so nothing to skip: the chan owners are first in the list - + // now strcmp within the current user-flag group... while(entry && (KviQString::cmpCI(entry->m_szNick,e->m_szNick) < 0) && ((entry->m_iFlags & flag) || (flag == 0))) @@ -652,6 +761,7 @@ bool KviUserListView::avatarChanged(const QString &nick) int oldH = it->m_iHeight; m_iTotalHeight -= it->m_iHeight; it->recalcSize(); + it->updateAvatarData(); m_iTotalHeight += it->m_iHeight; // if this was "over" the top item , we must adjust the scrollbar value // otherwise scroll everything down @@ -729,7 +839,7 @@ bool KviUserListView::userActionVerifyMask(const QString &nick,const QString &us bChanged = true; } it->m_pGlobalData->setUser(user); - } + } } it->m_iTemperature += actionTemperature; // Don't allow it to grow too much @@ -977,6 +1087,11 @@ bool KviUserListView::partInternal(const QString &nick,bool bRemove) } else e = e->m_pNext; } if(bRemove)m_pIrcUserDataBase->removeUser(nick,it->m_pGlobalData); + if(!m_pIrcUserDataBase->find(nick)) + { + //completelly removed. avatar is deleted + it->resetAvatarConnection(); + } // now just remove it if(it->m_iFlags & KVI_USERFLAG_OP)m_iOpCount--; @@ -1101,6 +1216,7 @@ void KviUserListView::removeAllEntries() KviPointerHashTableIterator<QString,KviUserListEntry> it(*m_pEntryDict); while(it.current()) { + it.current()->resetAvatarConnection(); m_pIrcUserDataBase->removeUser(it.currentKey(), ((KviUserListEntry *)it.current())->m_pGlobalData); ++it; @@ -1282,7 +1398,7 @@ void KviUserListView::maybeTip(KviUserListToolTip * tip,const QPoint &pnt) buffer += __tr2qs("Joined on <b>%1</b>").arg(dt.toString()); buffer += "</nobr></td></tr>"; } - + if(it->m_lastActionTime != 0) { int secs = kvi_unixTime() - it->m_lastActionTime; @@ -1295,7 +1411,7 @@ void KviUserListView::maybeTip(KviUserListToolTip * tip,const QPoint &pnt) buffer += "</nobr></td></tr>"; } buffer += "</table>"; - + tip->doTip(itRect,buffer); } } @@ -1439,7 +1555,7 @@ void KviUserListViewArea::paintEvent(QPaintEvent *ev) bool bShowIcons = KVI_OPTION_BOOL(KviOption_boolShowUserChannelIcons); bool bShowState = KVI_OPTION_BOOL(KviOption_boolShowUserChannelState); bool bShowGender = KVI_OPTION_BOOL(KviOption_boolDrawGenderIcons); - + while(e && theY <= r.bottom()) { int bottom = theY + e->m_iHeight; @@ -1451,19 +1567,23 @@ void KviUserListViewArea::paintEvent(QPaintEvent *ev) if(bottom >= r.top()) { QColor * pClrFore = 0; - bool bColorAllocated=0; // FIXME: bool is true or false + bool bColorAllocated=true; if(e->m_bSelected) { QColor col=KVI_OPTION_COLOR(KviOption_colorUserListViewSelectionBackground); col.setAlpha(150); p.fillRect(0,theY,wdth,e->m_iHeight,col); pClrFore = &(KVI_OPTION_COLOR(KviOption_colorUserListViewSelectionForeground)); + bColorAllocated = false; } else if(KVI_OPTION_BOOL(KviOption_boolUseDifferentColorForOwnNick) && m_pListView->m_pKviWindow->connection()) { if(e->m_szNick==m_pListView->m_pKviWindow->connection()->currentNickName()) + { pClrFore = &(KVI_OPTION_COLOR(KviOption_colorUserListViewOwnForeground)); - } - + bColorAllocated = false; + } + } + if(!pClrFore){ // FIXME: // @@ -1481,6 +1601,7 @@ void KviUserListViewArea::paintEvent(QPaintEvent *ev) if(e->m_iFlags == 0) { pClrFore = &(KVI_OPTION_COLOR(KviOption_colorUserListViewNormalForeground)); + bColorAllocated = false; } else { pClrFore = &(KVI_OPTION_COLOR((e->m_iFlags & KVI_USERFLAG_CHANOWNER) ? \ KviOption_colorUserListViewChanOwnerForeground : ((e->m_iFlags & KVI_USERFLAG_CHANADMIN) ? \ @@ -1488,14 +1609,15 @@ void KviUserListViewArea::paintEvent(QPaintEvent *ev) KviOption_colorUserListViewOpForeground : ((e->m_iFlags & KVI_USERFLAG_HALFOP) ? \ KviOption_colorUserListViewHalfOpForeground : ((e->m_iFlags & KVI_USERFLAG_VOICE) ? \ KviOption_colorUserListViewVoiceForeground : KviOption_colorUserListViewUserOpForeground)))))); + bColorAllocated = false; } } } - + int theX = KVI_USERLIST_BORDER_WIDTH + 1; - + int iAvatarAndTextX = theX; - + if(bShowGender)iAvatarAndTextX += 11; if(bShowIcons)iAvatarAndTextX += 18; if(bShowState)iAvatarAndTextX += 11; @@ -1542,23 +1664,29 @@ void KviUserListViewArea::paintEvent(QPaintEvent *ev) p.setPen(*pClrFore); } theY+=2; - + + //TODO: avatar animations if(!KVI_OPTION_BOOL(KviOption_boolDisableAvatars))//G&N 2005 { KviAvatar * av = e->m_pGlobalData->avatar(); if(av && KVI_OPTION_UINT(KviOption_uintAvatarScaleWidth) && KVI_OPTION_UINT(KviOption_uintAvatarScaleHeight)) { - QPixmap * pix; + QPixmap* pix; if( KVI_OPTION_BOOL(KviOption_boolScaleAvatars) && ( !KVI_OPTION_BOOL(KviOption_boolDoNotStretchAvatars) || - (av->pixmap()->width() > KVI_OPTION_UINT(KviOption_uintAvatarScaleWidth)) || - (av->pixmap()->height() > KVI_OPTION_UINT(KviOption_uintAvatarScaleHeight)) + (av->size().width() > KVI_OPTION_UINT(KviOption_uintAvatarScaleWidth)) || + (av->size().height() > KVI_OPTION_UINT(KviOption_uintAvatarScaleHeight)) ) - ) - pix=av->scaledPixmap(KVI_OPTION_UINT(KviOption_uintAvatarScaleWidth),KVI_OPTION_UINT(KviOption_uintAvatarScaleHeight)); - else + ) { + pix=av->forSize( + KVI_OPTION_UINT(KviOption_uintAvatarScaleWidth), + KVI_OPTION_UINT(KviOption_uintAvatarScaleHeight) + )->pixmap(); + } else { pix=av->pixmap(); + } + //debug("Pixmap: null=%i;height=%i;width=%i",pix.isNull(),pix.height(),pix.width()); p.drawPixmap(iAvatarAndTextX,theY,*pix); theY += pix->height() + 1; } @@ -1640,12 +1768,12 @@ void KviUserListViewArea::paintEvent(QPaintEvent *ev) // bit-cold p.drawPixmap(theX,theY,*g_pUserChanStatePixmap,xOffTable[uTimeDiff],48,8,16); } - } + } } } theX += 11; } - + if(bShowIcons) { //p.drawRect(theX,theY + 2,18,e->m_iHeight - 4); @@ -1694,7 +1822,7 @@ void KviUserListViewArea::paintEvent(QPaintEvent *ev) e = e->m_pNext; } - //we really do not need any self-draw borders. + //we really do not need any self-draw borders. //if we will need it, we will draw a better one with system style //p.setPen(colorGroup().dark()); @@ -1789,6 +1917,19 @@ void KviUserListViewArea::keyPressEvent( QKeyEvent * e ) { if(m_pListView->m_pKviWindow->input()) ((QWidget*)(m_pListView->m_pKviWindow->input()))->setFocus(); + } else if ( + e->modifiers().testFlag(Qt::ControlModifier) && + e->key() == 'a' + ){ + KviUserListEntry * aux = m_pListView->m_pHeadItem; + while(aux) + { + aux->m_bSelected = true; + aux = aux->m_pNext; + } + + g_pFrame->childWindowSelectionStateChange(m_pListView->m_pKviWindow,true); + update(); } else { QString szKey=e->text(); if(!szKey.isEmpty()) @@ -1798,7 +1939,7 @@ void KviUserListViewArea::keyPressEvent( QKeyEvent * e ) while(aux) { //debug("%s %s %i %s %i",__FILE__,__FUNCTION__,__LINE__,aux->nick().toUtf8().data(),aux->nick().find(szKey,0,0)); - if(aux->nick().indexOf(szKey,0,Qt::CaseInsensitive)==0) + if(aux->nick().indexOf(szKey,0,Qt::CaseInsensitive)==0) { nick=aux; break; diff --git a/src/kvirc/ui/kvi_userlistview.h b/src/kvirc/ui/kvi_userlistview.h index 74e4e6d95..fa3856a3b 100644 --- a/src/kvirc/ui/kvi_userlistview.h +++ b/src/kvirc/ui/kvi_userlistview.h @@ -87,18 +87,21 @@ protected: bool m_bSelected; KviUserListEntry * m_pNext; KviUserListEntry * m_pPrev; + KviAnimatedPixmap* m_pConnectedAnimation; public: short int flags() const { return m_iFlags; }; KviIrcUserEntry * globalData(){ return m_pGlobalData; }; const QString &nick() const { return m_szNick; }; KviUserListEntry * next(){ return m_pNext; }; bool color(QColor& color); + void updateAvatarData(); + void resetAvatarConnection(); protected: void recalcSize(); }; -typedef struct _KviUserListViewUserStats +typedef struct _KviUserListViewUserStats { unsigned int uTotal; // total users on the channel unsigned int uActive; // active users in the last 10 mins @@ -220,6 +223,8 @@ public: void emitDoubleClick(); bool completeNickStandard(const QString &begin,const QString &skipAfter,QString &buffer,bool bAppendMask); void completeNickBashLike(const QString &begin,KviPointerList<QString> * l,bool bAppendMask); +public slots: + void animatedAvatarUpdated(); }; class KVIRC_API KviUserListViewArea : public QWidget diff --git a/src/modules/options/optw_userlist.cpp b/src/modules/options/optw_userlist.cpp index 0200fed84..592a3c3aa 100644 --- a/src/modules/options/optw_userlist.cpp +++ b/src/modules/options/optw_userlist.cpp @@ -231,8 +231,9 @@ KviUserListFeaturesOptionsWidget::KviUserListFeaturesOptionsWidget(QWidget * par b = addBoolSelector(0,3,0,3,__tr2qs_ctx("Hide users label","options"),KviOption_boolDisableUserListLabel); b = addBoolSelector(0,4,0,4,__tr2qs_ctx("Enable user tooltips","options"),KviOption_boolShowUserListViewToolTips); b = addBoolSelector(0,5,0,5,__tr2qs_ctx("Hide avatars","options"),KviOption_boolDisableAvatars); + b = addBoolSelector(0,6,0,6,__tr2qs_ctx("Enable animated avatars","options"),KviOption_boolEnableAnimatedAvatars); - addRowSpacer(0,6,0,6); + addRowSpacer(0,7,0,7); } KviUserListFeaturesOptionsWidget::~KviUserListFeaturesOptionsWidget() |
