Ticket #4013: promptSchema.patch
File promptSchema.patch, 4.0 KB (added by , 17 years ago) |
---|
-
libs/libmyth/mythcontext.h
382 382 void SetMainWindow(MythMainWindow *mainwin); 383 383 MythMainWindow *GetMainWindow(void); 384 384 385 int PromptForSchemaUpgrade(const QString &message); 385 386 bool TestPopupVersion(const QString &name, const QString &libversion, 386 387 const QString &pluginversion); 387 388 -
libs/libmyth/mythcontext.cpp
504 559 { 505 560 imageCache.clear(); 506 561 562 if (m_UPnP) 563 delete m_UPnP; 507 564 if (m_settings) 508 565 delete m_settings; 509 566 if (m_qtThemeSettings) … … 788 845 cout << " [" << def << "] "; 789 846 else 790 847 cout << " "; 791 848 849 if (!isatty(fileno(stdin)) || !isatty(fileno(stdout))) 850 { 851 cout << endl << "[console is not interactive, using default '" 852 << def << "']" << endl; 853 return def; 854 } 855 792 856 char response[80]; 793 857 cin.clear(); 794 858 cin.getline(response, 80); … … 2870 2988 return d->mainWindow; 2871 2989 } 2872 2990 2991 2992 int MythContext::PromptForSchemaUpgrade(const QString &message) 2993 { 2994 if (d->m_gui) 2995 { 2996 QStringList buttonNames; 2997 bool createdTempWindow = false; 2998 int selected; 2999 3000 buttonNames += QObject::tr("Use old schema"); 3001 buttonNames += QObject::tr("Upgrade"); 3002 buttonNames += QObject::tr("Exit program"); 3003 3004 3005 if (!d->mainWindow) 3006 { 3007 d->TempMainWindow(); 3008 createdTempWindow = true; 3009 } 3010 3011 selected = MythPopupBox::showButtonPopup(d->mainWindow, 3012 "Database Upgrade", 3013 message, buttonNames, -1); 3014 3015 if (createdTempWindow) 3016 d->EndTempWindow(); 3017 3018 return selected; 3019 } 3020 3021 QString resp; 3022 3023 cout << endl << message << endl << endl; 3024 3025 resp = d->getResponse("Would you like to upgrade this database?", "yes"); 3026 if (!resp || resp.left(1).lower() == "y") 3027 return 1; 3028 3029 resp = d->getResponse("You can try using the existing database, or exit." 3030 "\nWould you like to exit the program?", "no"); 3031 if (!resp || resp.left(1).lower() == "n") 3032 return 0; 3033 3034 return 2; 3035 } 3036 2873 3037 bool MythContext::TestPopupVersion(const QString &name, 2874 3038 const QString &libversion, 2875 3039 const QString &pluginversion) -
libs/libmythtv/dbcheck.cpp
426 426 if (dbver == currentDatabaseVersion) 427 427 return true; 428 428 429 if (!gContext->GetNumSetting("DBSchemaAutoUpgrade")) 430 { 431 QString message; 432 message = QObject::tr("Warning: MythTV wants to upgrade" 433 " your database schema, from %1 to %2. " 434 "This cannot be un-done, so having" 435 " a database backup is a good idea.\n\n" 436 "You can try using this program with the" 437 " old schema, but that may cause problems."); 438 message = message.arg(dbver).arg(currentDatabaseVersion); 439 440 switch (gContext->PromptForSchemaUpgrade(message)) 441 { 442 case 0: // Use existing schema (i.e. don't upgrade) 443 return true; 444 case 1: // Upgrade 445 break; 446 default: // Exit/error 447 return false; 448 } 449 } 450 429 451 MSqlQuery chartype(MSqlQuery::InitCon()); 430 452 chartype.prepare("ALTER DATABASE mythconverg DEFAULT CHARACTER SET latin1;"); 431 453 chartype.exec();