| 2663 | |
| 2664 | |
| 2665 | bool WizDatabase::open(const QString& strAccountFolderName, const QString& strKbGUID /* = NULL */) |
| 2666 | { |
| 2667 | Q_ASSERT(!strAccountFolderName.isEmpty()); |
| 2668 | |
| 2669 | m_strAccountFolderName = strAccountFolderName; |
| 2670 | |
| 2671 | if (strKbGUID.isEmpty()) { |
| 2672 | m_bIsPersonal = true; |
| 2673 | } else { |
| 2674 | m_bIsPersonal = false; |
| 2675 | setKbGUID(strKbGUID); |
| 2676 | } |
| 2677 | |
| 2678 | if (!WizIndex::open(getIndexFileName())) { |
| 2679 | // If can not open db, try again. If db still can not be opened, delete the db file and download data from server. |
| 2680 | if (!WizIndex::open(getIndexFileName())) { |
| 2681 | QFile::remove(getIndexFileName()); |
| 2682 | return false; |
| 2683 | } |
| 2684 | } |
| 2685 | |
| 2686 | // user private database opened, try to load kb guid |
| 2687 | if (strKbGUID.isEmpty()) { |
| 2688 | // user private kb_guid should be set before actually open for operating |
| 2689 | QString strUserKbGuid = getMetaDef(g_strDatabaseInfoSection, "KBGUID"); |
| 2690 | if (!strUserKbGuid.isEmpty()) |
| 2691 | setKbGUID(strUserKbGuid); |
| 2692 | } |
| 2693 | |
| 2694 | // FIXME |
| 2695 | if (!WizThumbIndex::openThumb(getThumbFileName(), getThumIndexVersion())) { |
| 2696 | // If can not open db, try again. If db still can not be opened, delete the db file and download data from server. |
| 2697 | if (!WizThumbIndex::openThumb(getThumbFileName(), getThumIndexVersion())) { |
| 2698 | QFile::remove(getThumbFileName()); |
| 2699 | return false; |
| 2700 | } |
| 2701 | } |
| 2702 | |
| 2703 | setThumbIndexVersion(WIZNOTE_THUMB_VERSION); |
| 2704 | |
| 2705 | loadDatabaseInfo(); |
| 2706 | |
| 2707 | return true; |
| 2708 | } |
| 2709 | |
| 2710 | bool WizDatabase::loadDatabaseInfo() |
| 2711 | { |
no test coverage detected