| 29 | } |
| 30 | |
| 31 | bool WizDatabaseManager::openWithInfo(const QString& strKbGUID, const WIZDATABASEINFO* pInfo) |
| 32 | { |
| 33 | Q_ASSERT(!m_strAccountFolderName.isEmpty()); |
| 34 | |
| 35 | if (isOpened(strKbGUID)) |
| 36 | return true; |
| 37 | |
| 38 | WizDatabase* db = new WizDatabase(); |
| 39 | |
| 40 | if (!db->open(m_strAccountFolderName, strKbGUID)) { |
| 41 | delete db; |
| 42 | return false; |
| 43 | } |
| 44 | |
| 45 | if (pInfo) |
| 46 | { |
| 47 | db->initDatabaseInfo(*pInfo); |
| 48 | } |
| 49 | |
| 50 | if (strKbGUID.isEmpty()) { |
| 51 | m_dbPrivate = db; |
| 52 | |
| 53 | // take ownership immediately |
| 54 | connect(db, SIGNAL(databaseOpened(WizDatabase*, const QString&)), |
| 55 | SLOT(on_groupDatabaseOpened(WizDatabase*, const QString&)), |
| 56 | Qt::BlockingQueuedConnection); |
| 57 | } else { |
| 58 | m_mapGroups[strKbGUID] = db; |
| 59 | } |
| 60 | |
| 61 | initSignals(db); |
| 62 | |
| 63 | Q_EMIT databaseOpened(strKbGUID); |
| 64 | return true; |
| 65 | } |
| 66 | |
| 67 | bool WizDatabaseManager::open(const QString& strKbGUID) |
| 68 | { |
| 69 | return openWithInfo(strKbGUID, NULL); |
| 70 | } |
| 71 | |
| 72 | bool WizDatabaseManager::openAll() |
| 73 | { |
| 74 | // first, open private db |
| 75 | if (!open()) { |
| 76 | TOLOG("open user private database failed"); |
| 77 | return false; |
| 78 | } |
| 79 | |
| 80 | // second, get groups info |
| 81 | CWizGroupDataArray arrayGroup; |
| 82 | if (!m_dbPrivate->getAllGroupInfo(arrayGroup)) { |
| 83 | TOLOG("Failed to get user group info"); |
| 84 | return true; |
| 85 | } |
| 86 | |
| 87 | // third, open groups one by one |
| 88 | CWizGroupDataArray::const_iterator it; |
nothing calls this directly
no test coverage detected