397{
399
401
402
404 strcat(path, "update.log");
406 {
407 bool silent = true;
409 }
410
411
412
413
415
416
417
418
419 if (pluginNumber != -1)
420 {
423 {
425 {
429
433
434 sprintf(parameter, "%s.version:", plugin);
435 strcpy(onlineVersion,
ReadString(path, parameter,
""));
436 if (!strlen(onlineVersion))
437 {
438 pluginList[pluginNumber].UpdateAvailable =
false;
441 sprintf(msg, "%s \n\n%s is not supported by the specified repository! ", temp, plugin);
442 MessageBox(
GetBBWnd(), msg,
"xoblite", MB_OK | MB_SETFOREGROUND | MB_ICONERROR);
443 return;
444 }
445 sprintf(parameter, "%s.date:", plugin);
446 strcpy(onlineDate,
ReadString(path, parameter,
"xxxx-xx-xx"));
447
448
449
450
451 if (!_stricmp(currentDate, onlineDate))
452 {
453 if (!_stricmp(currentVersion, onlineVersion))
454 {
455 pluginList[pluginNumber].UpdateAvailable =
false;
456 sprintf(msg, "You are already using the latest version of %s. ", plugin);
457 MessageBox(
GetBBWnd(), msg,
"xoblite", MB_OK | MB_SETFOREGROUND | MB_ICONINFORMATION);
458 return;
459 }
460 }
461
462
463
464 sprintf(msg, "%s update found!\n\nCurrent version:\t %s \t%s \nOnline version:\t %s \t%s ", plugin, currentVersion, currentDate, onlineVersion, onlineDate);
465
466 sprintf(parameter, "%s.changes:", plugin);
467 strcpy(temp,
ReadString(path, parameter,
""));
468 if (strlen(temp))
469 {
470 strcat(msg, "\n\nUpdate information:\n");
471 strcat(msg, temp);
472 }
473
474 strcat(msg, "\n\nDo you want to download this update? ");
475
476
477
478 if (MessageBox(
GetBBWnd(), msg,
"xoblite", MB_YESNO | MB_ICONQUESTION | MB_SETFOREGROUND | MB_TOPMOST) == IDYES)
479 {
480 int nLen;
483 LPSTR tokens[1];
484 tokens[0] = token;
485
486
487 bool dllFound = false, zipFound = false;
488
489 if (!strstr(
pluginList[pluginNumber].path,
":\\"))
490 {
491
492
494 strcat(filename,
pluginList[pluginNumber].path);
495 }
496 else strcpy(filename,
pluginList[pluginNumber].path);
497
498 sprintf(parameter, "%s.files:", plugin);
499 strcpy(temp,
ReadString(path, parameter,
""));
500 if (!strlen(temp))
501 {
502
503
504 sprintf(parameter, "%s.archive:", plugin);
505 strcpy(temp,
ReadString(path, parameter,
""));
506 }
507
508 if (
IsInString(temp,
".dll")) dllFound =
true;
509 else if (
IsInString(temp,
".zip")) zipFound =
true;
510
511 if (!dllFound && !zipFound)
512 {
513
514
516 else
517 {
518 sprintf(msg, "Invalid update link detected for %s: \n\n%s ", plugin, temp);
519 if (strlen(temp) == 0) strcat(msg, "<empty> ");
520 strcat(msg, "\n\nUpdate request aborted. Click OK to continue.");
521 MessageBox(
GetBBWnd(), msg,
"Error updating plugin!", MB_ICONERROR | MB_SETFOREGROUND | MB_TOPMOST);
522 }
523 return;
524 }
525
526 if (dllFound)
527 {
528
529 strcpy(pluginPath,
pluginList[pluginNumber].path);
534 }
535
536
537 while(strlen(temp))
538 {
539 token[0] = extra[0] = '\0';
541 strcpy(temp, extra);
542
543
544 nLen = strlen(filename) - 1;
545 if (
IsInString(filename,
"/"))
while (nLen >0 && filename[nLen] !=
'/') nLen--;
546 else while (nLen >0 && filename[nLen] != '\\') nLen--;
547 filename[nLen + 1] = 0;
548
549
550 nLen = strlen(token) - 1;
551 while (nLen >0 && token[nLen] != '/') nLen--;
552 strcat(filename, &token[nLen+1]);
553
554
556
557
558 strcat(savedfiles, "\n");
559 strcat(savedfiles, filename);
560 strcat(savedfiles, " ");
561 }
562
563 if (dllFound)
564 {
565
566 bool dockingEnabled;
567
568 if (pluginPath[0] == '&')
569 {
570 dockingEnabled = true;
571 hModule = LoadLibrary(&pluginPath[1]);
572 }
573 else
574 {
575 dockingEnabled = false;
576 hModule = LoadLibrary(pluginPath);
577 }
578
580 {
582 {
583 pluginItem plg;
586 strcpy(plg.
path, pluginPath);
589 }
590 }
591 else return;
592
593 sprintf(msg, "%s update downloaded and installed. \n%s", plugin, savedfiles);
594 MessageBox(
GetBBWnd(), msg,
"xoblite", MB_OK | MB_SETFOREGROUND | MB_TOPMOST | MB_ICONINFORMATION);
595 }
596 else if (zipFound)
597 {
598 sprintf(msg, "%s update in .zip format downloaded, \nsee archive for further instructions. \n%s", plugin, savedfiles);
599 if (MessageBox(
GetBBWnd(), msg,
"xoblite", MB_OK | MB_SETFOREGROUND | MB_TOPMOST | MB_ICONINFORMATION))
600 {
602 strcpy(arg, "/e,/select,");
603 strcat(arg, savedfiles);
604 BBExecute(GetDesktopWindow(), NULL,
"explorer.exe", arg, NULL, SW_SHOWNORMAL,
false);
605 return;
606 }
607 }
608 else
609 {
610 sprintf(msg, "%s update downloaded. \n%s", plugin, savedfiles);
611 MessageBox(
GetBBWnd(), msg,
"xoblite", MB_OK | MB_SETFOREGROUND | MB_TOPMOST | MB_ICONINFORMATION);
612 }
613 }
614
615
616 pluginList[pluginNumber].UpdateAvailable =
false;
617 }
618 else MessageBox(
GetBBWnd(),
"Could not find the updates metafile! [update.log] ",
"xoblite", MB_OK | MB_SETFOREGROUND | MB_TOPMOST | MB_ICONERROR);
619 }
620 else MessageBox(
GetBBWnd(),
"This plugin does not support automatic updating. ",
"xoblite", MB_OK | MB_SETFOREGROUND | MB_TOPMOST | MB_ICONERROR);
621 }
622
623
625
626}
bool DownloadFile(LPCSTR url, LPCSTR path)
Definition BBApi.cpp:3296
LPSTR ReadString(LPCSTR fp, LPCSTR szString, LPSTR szDefault)
Definition BBApi.cpp:544
void BBSmartExecute(LPSTR inputString)
Definition BBApi.cpp:1767
bool FileExists(LPCSTR szFileName)
Definition BBApi.cpp:819
bool WINAPI GetBlackboxPath(LPSTR pszPath, int nMaxLen)
Definition BBApi.cpp:214
int BBTokenize(LPCSTR szString, char *lpszBuffers[], DWORD dwNumBuffers, LPSTR szExtraParameters)
Definition BBApi.cpp:316
HINSTANCE BBExecute(HWND Owner, LPCSTR szOperation, LPCSTR szCommand, LPCSTR szArgs, LPCSTR szDirectory, int nShowCmd, bool noErrorMsgs)
Definition BBApi.cpp:1648
#define PLUGIN_UPDATE_URL
Definition BBApi.h:273
#define PLUGIN_RELEASEDATE
Definition BBApi.h:269
#define PLUGIN_VERSION
Definition BBApi.h:267
void checkForUpdates(void *param)
Definition PluginManager.cpp:630
char pluginsRepository[MAX_LINE_LENGTH]
Definition Settings.h:316