Changeset 831
- Timestamp:
- 2003-03-17 02:24:46 (6 years ago)
- Files:
-
- mb_tagger/trunk/main.dfm (modified) (5 diffs)
- mb_tagger/trunk/preferences.cpp (modified) (3 diffs)
- mb_tagger/trunk/preferences.h (modified) (1 diff)
- mb_tagger/trunk/utf8.c (modified) (4 diffs)
- mb_tagger/trunk/vcedit.c (modified) (13 diffs)
- mb_tagger/trunk/vorbis.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
mb_tagger/trunk/main.dfm
r827 r831 5 5 AutoScroll = False 6 6 Caption = 'MusicBrainz Tagger' 7 ClientHeight = 7 507 ClientHeight = 739 8 8 ClientWidth = 792 9 9 Color = clBtnFace … … 151 151 object statusBar: TStatusBar 152 152 Left = 0 153 Top = 7 31153 Top = 720 154 154 Width = 792 155 155 Height = 19 … … 997 997 Top = 215 998 998 Width = 792 999 Height = 5 16999 Height = 505 1000 1000 Align = alClient 1001 1001 Caption = 'rightPanel' … … 1006 1006 Top = 1 1007 1007 Width = 790 1008 Height = 5 141008 Height = 503 1009 1009 TabStop = True 1010 1010 Align = alClient … … 1014 1014 OnDocumentComplete = webBrowserDocumentComplete 1015 1015 ControlData = { 1016 4C000000A6510000 2035000000000000000000000000000000000000000000001016 4C000000A6510000FD3300000000000000000000000000000000000000000000 1017 1017 000000004C000000000000000000000001000000E0D057007335CF11AE690800 1018 1018 2B2E126200000000000000004C0000000114020000000000C000000000000046 mb_tagger/trunk/preferences.cpp
r829 r831 164 164 } 165 165 166 prefs.proxyServer = AnsiString(""); 166 167 INTERNET_PROXY_INFO *info = (INTERNET_PROXY_INFO *)new char[size]; 167 168 if (InternetQueryOption(NULL, INTERNET_OPTION_PROXY, info, &size)) … … 174 175 } 175 176 } 177 #if 0 178 if (prefs.proxyServer.IsEmpty()) 179 { 180 AnsiString autoProxy; 181 182 if (getAutoProxy(autoProxy)) 183 { 184 char temp[128]; 185 sscanf(info->lpszProxy, "%[^:]:%d", temp, &prefs.proxyPort); 186 prefs.proxyServer = AnsiString(temp); 187 } 188 } 189 #endif 190 176 191 delete [] info; 177 192 … … 223 238 } 224 239 240 #if 0 241 typedef bool (WINAPI *pfnGetProxyInfo)(LPCSTR, DWORD, LPSTR, DWORD, LPSTR *, LPDWORD); 242 typedef bool (WINAPI *pfnInitializeAutoProxyDll)(DWORD); 243 typedef bool (WINAPI *pfnDeInitializeAutoProxyDll)(LPSTR, DWORD); 244 245 bool __fastcall Preferences::getAutoProxy(AnsiString &proxyString) 246 { 247 HMODULE hModJS; // Handle for loading the DLL 248 pfnGetProxyInfo pIGPI; // Function-pointer instance 249 pfnDeInitializeAutoProxyDll pIIDAPD; // Function-pointer instance 250 pfnInitializeAutoProxyDll pIIIAPD; 251 unsigned long proxyLen = 0; 252 char *proxy = NULL; 253 const char *url = "http://musicbrainz.org/index.html"; 254 const char *hostName = "musicbrainz.org"; 255 bool ret = false; 256 257 proxyString = ""; 258 259 hModJS = LoadLibrary( "jsproxy.dll" ); 260 if (!hModJS) 261 return false; 262 263 pIGPI = (pfnGetProxyInfo)GetProcAddress( hModJS, "InternetGetProxyInfo"); 264 if (!pIGPI) 265 return false; 266 267 pIIIAPD= (pfnInitializeAutoProxyDll) 268 GetProcAddress( hModJS, "InternetInitializeAutoProxyDll" ); 269 if (!pIIIAPD) 270 return false; 271 272 pIIDAPD = (pfnDeInitializeAutoProxyDll) 273 GetProcAddress(hModJS, "InternetDeInitializeAutoProxyDll"); 274 if (!pIIDAPD) 275 return false; 276 277 // Initialize the M$ crap 278 pIIIAPD(0); 279 280 if (pIGPI(url, strlen(url), (char *)hostName, strlen(hostName), &proxy, &proxyLen)) 281 { 282 proxyString = AnsiString(proxy); 283 ret = true; 284 } 285 286 // Shut it down; good riddance 287 pIIDAPD( NULL, 0 ); 288 289 return ret; 290 } 291 #endif mb_tagger/trunk/preferences.h
r829 r831 66 66 PreferenceValues prefs; 67 67 68 //bool __fastcall getAutoProxy(AnsiString &proxyString); 68 69 }; 69 70 mb_tagger/trunk/utf8.c
r828 r831 138 138 139 139 if(wchars == 0) 140 {141 fprintf(stderr, "Unicode translation error %d\n", GetLastError());142 140 return -1; 143 }144 141 145 142 unicode = calloc(wchars + 1, sizeof(unsigned short)); 146 if(unicode == NULL) 147 { 148 fprintf(stderr, "Out of memory processing string to UTF8\n"); 143 if(unicode == NULL) 149 144 return -1; 150 } 151 152 err = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, from, 145 146 err = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, from, 153 147 strlen(from), unicode, wchars); 154 148 if(err != wchars) 155 149 { 156 150 free(unicode); 157 fprintf(stderr, "Unicode translation error %d\n", GetLastError());158 151 return -1; 159 152 } … … 178 171 unicode = make_unicode_string(from); 179 172 if(unicode == NULL) 180 {181 fprintf(stderr, "Out of memory processing string from UTF8 to UNICODE16\n");182 173 return -1; 183 }184 174 185 175 chars = WideCharToMultiByte(GetConsoleCP(), WC_COMPOSITECHECK, unicode, … … 194 184 195 185 *to = calloc(chars + 1, sizeof(unsigned char)); 196 if(*to == NULL) 186 if(*to == NULL) 197 187 { 198 188 fprintf(stderr, "Out of memory processing string to local charset\n"); … … 201 191 } 202 192 203 err = WideCharToMultiByte(GetConsoleCP(), WC_COMPOSITECHECK, unicode, 193 err = WideCharToMultiByte(GetConsoleCP(), WC_COMPOSITECHECK, unicode, 204 194 -1, *to, chars, NULL, NULL); 205 195 if(err != chars) mb_tagger/trunk/vcedit.c
r819 r831 43 43 static void vcedit_clear_internals(vcedit_state *state) 44 44 { 45 char *tmp; 45 46 if(state->vc) 46 47 { … … 69 70 } 70 71 72 tmp = state->lasterror; 71 73 memset(state, 0, sizeof(*state)); 74 state->lasterror = tmp; 72 75 } 73 76 … … 98 101 oggpack_writeinit(&opb); 99 102 100 /* preamble */ 103 /* preamble */ 101 104 oggpack_write(&opb,0x03,8); 102 105 _v_writestring(&opb,"vorbis", 6); … … 113 116 if(vc->user_comments[i]){ 114 117 oggpack_write(&opb,vc->comment_lengths[i],32); 115 _v_writestring(&opb,vc->user_comments[i], 118 _v_writestring(&opb,vc->user_comments[i], 116 119 vc->comment_lengths[i]); 117 120 }else{ … … 197 200 char *buffer; 198 201 int bytes,i; 202 int chunks = 0; 199 203 ogg_packet *header; 200 204 ogg_packet header_main; … … 210 214 ogg_sync_init(state->oy); 211 215 212 buffer = ogg_sync_buffer(state->oy, CHUNKSIZE); 213 bytes = state->read(buffer, 1, CHUNKSIZE, state->in); 214 215 ogg_sync_wrote(state->oy, bytes); 216 217 if(ogg_sync_pageout(state->oy, &og) != 1) 218 { 219 if(bytes<CHUNKSIZE) 220 state->lasterror = _("Input truncated or empty."); 221 else 222 state->lasterror = _("Input is not an Ogg bitstream."); 223 goto err; 224 } 216 while(1) 217 { 218 buffer = ogg_sync_buffer(state->oy, CHUNKSIZE); 219 bytes = state->read(buffer, 1, CHUNKSIZE, state->in); 220 221 ogg_sync_wrote(state->oy, bytes); 222 223 if(ogg_sync_pageout(state->oy, &og) == 1) 224 break; 225 226 if(chunks++ >= 10) /* Bail if we don't find data in the first 40 kB */ 227 { 228 if(bytes<CHUNKSIZE) 229 state->lasterror = _("Input truncated or empty."); 230 else 231 state->lasterror = _("Input is not an Ogg bitstream."); 232 goto err; 233 } 234 } 225 235 226 236 state->serial = ogg_page_serialno(&og); … … 343 353 ogg_stream_init(&streamout, state->serial); 344 354 355 memset(&header_comments, 0, sizeof(header_comments)); 345 356 _commentheader_out(state->vc, state->vendor, &header_comments); 346 357 … … 354 365 (size_t) ogout.header_len) 355 366 goto cleanup; 356 if(state->write(ogout.body,1,ogout.body_len, out) != 367 if(state->write(ogout.body,1,ogout.body_len, out) != 357 368 (size_t) ogout.body_len) 358 369 goto cleanup; … … 369 380 if(ogg_stream_flush(&streamout, &ogout)) 370 381 { 371 if(state->write(ogout.header,1,ogout.header_len, 382 if(state->write(ogout.header,1,ogout.header_len, 372 383 out) != (size_t) ogout.header_len) 373 384 goto cleanup; … … 384 395 out) != (size_t) ogout.header_len) 385 396 goto cleanup; 386 if(state->write(ogout.body,1,ogout.body_len, 397 if(state->write(ogout.body,1,ogout.body_len, 387 398 out) != (size_t) ogout.body_len) 388 399 goto cleanup; … … 411 422 needout=1; 412 423 } 413 } 424 } 414 425 } 415 426 … … 453 464 if(state->write(ogout.header,1,ogout.header_len, 454 465 out) != (size_t) ogout.header_len) { 455 fprintf(stderr, "Bumming out\n");456 466 goto cleanup; 457 467 } 458 468 if(state->write(ogout.body,1,ogout.body_len, out) != 459 469 (size_t) ogout.body_len) { 460 fprintf(stderr, "Bumming out 2\n");461 470 goto cleanup; 462 471 } … … 472 481 } 473 482 } 474 483 475 484 476 485 cleanup: 486 477 487 ogg_stream_clear(&streamout); 488 if (header_comments.packet) 489 { 490 _ogg_free(header_comments.packet); 491 header_comments.packet = NULL; 492 } 478 493 ogg_packet_clear(&header_comments); 479 494 mb_tagger/trunk/vorbis.cpp
r830 r831 92 92 key = entry.substr(0, sep); 93 93 94 utf8_decode (entry.substr(sep+1, string::npos).c_str(), &decoded);95 val = decoded;96 if (decoded)97 {98 free (decoded);99 decoded = NULL;94 decoded = NULL; 95 if (utf8_decode (entry.substr(sep+1, string::npos).c_str(), &decoded) == 0) 96 { 97 val = decoded; 98 if (decoded) 99 free (decoded); 100 100 } 101 101 102 102 transform(key.begin(),key.end(),key.begin(),(int(*)(int))&tolower); 103 103 map.insert (pair<string,string>(key, val)); 104 // cerr << "found " << key << " with " << val << endl;105 104 } 106 105 } … … 123 122 transform(key.begin(),key.end(),key.begin(),(int(*)(int))&toupper); 124 123 125 utf8_encode ((*it).second.c_str(), &encoded); 126 comment = key + '=' + encoded; 127 free (encoded); 124 encoded = NULL; 125 if (utf8_encode ((*it).second.c_str(), &encoded) == 0) 126 { 127 comment = key + '=' + encoded; 128 if (encoded) 129 free (encoded); 130 } 128 131 129 132 vorbis_comment_add (vc, (char*)comment.c_str());