~ubuntu-branches/ubuntu/lucid/mythplugins/lucid

« back to all changes in this revision

Viewing changes to mythmusic/mythmusic/dbcheck.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mario Limonciello
  • Date: 2009-09-08 23:35:10 UTC
  • mfrom: (1.1.27 upstream)
  • Revision ID: james.westby@ubuntu.com-20090908233510-uvcvmvbn73khqark
Tags: 0.22.0~trunk21742-0ubuntu1
* New upstream checkout (r21742)
* debian/rules, debian/mythvideo.cron.daily:
  - Install jamu cron job
* debian/control:
  - Depends on python-imdbpy for mythvideo's new jamu cron job.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <qstring.h>
2
 
#include <qdir.h>
3
 
//Added by qt3to4:
 
1
#include <QString>
 
2
#include <QDir>
4
3
#include <QSqlError>
5
4
 
6
5
#include <iostream>
10
9
#include "metadata.h"
11
10
#include "mythtv/mythcontext.h"
12
11
#include "mythtv/mythdb.h"
 
12
#include "mythtv/schemawizard.h"
13
13
 
14
14
const QString currentDatabaseVersion = "1017";
15
15
 
 
16
static bool doUpgradeMusicDatabaseSchema(QString &dbver);
 
17
 
16
18
static bool UpdateDBVersionNumber(const QString &newnumber)
17
19
{
18
20
 
66
68
 
67
69
bool UpgradeMusicDatabaseSchema(void)
68
70
{
69
 
    QString dbver = gContext->GetSetting("MusicDBSchemaVer");
70
 
 
71
 
    if (dbver == currentDatabaseVersion)
 
71
    SchemaUpgradeWizard  * DBup;
 
72
 
 
73
 
 
74
    gContext->ActivateSettingsCache(false);
 
75
 
 
76
    DBup = SchemaUpgradeWizard::Get("MusicDBSchemaVer",
 
77
                                    currentDatabaseVersion);
 
78
 
 
79
    // There may be a race condition where another frontend is upgrading,
 
80
    // so wait up to 3 seconds for a more accurate version:
 
81
    DBup->CompareAndWait(3);
 
82
 
 
83
    if (DBup->versionsBehind == 0)  // same schema
 
84
    {
 
85
        gContext->ActivateSettingsCache(true);
72
86
        return true;
73
 
 
 
87
    }
 
88
 
 
89
    bool retVal;
 
90
 
 
91
    if (DBup->DBver.isEmpty())
 
92
    {
 
93
        retVal = doUpgradeMusicDatabaseSchema(DBup->DBver);
 
94
        gContext->ActivateSettingsCache(true);
 
95
        return retVal;
 
96
    }
 
97
 
 
98
 
 
99
    // Pop up messages, questions, warnings, et c.
 
100
    switch (DBup->PromptForUpgrade("Music", true, false))
 
101
    {
 
102
        case MYTH_SCHEMA_USE_EXISTING:
 
103
            gContext->ActivateSettingsCache(true);
 
104
            return true;
 
105
        case MYTH_SCHEMA_ERROR:
 
106
        case MYTH_SCHEMA_EXIT:
 
107
            return false;
 
108
        case MYTH_SCHEMA_UPGRADE:
 
109
            break;
 
110
    }
 
111
 
 
112
    retVal = doUpgradeMusicDatabaseSchema(DBup->DBver);
 
113
    gContext->ActivateSettingsCache(true);
 
114
    return retVal;
 
115
}
 
116
 
 
117
 
 
118
static bool doUpgradeMusicDatabaseSchema(QString &dbver)
 
119
{
74
120
    if (dbver.isEmpty())
75
121
    {
76
122
        VERBOSE(VB_IMPORTANT, "Inserting MythMusic initial database information.");