示例#1
0
FolderList get_bookmark_folders() {
    FolderList folders;

    sqlite3 *db;
    sqlite3_stmt *stmt;
    std::string sql = "SELECT folderId, folder FROM folders ORDER BY folder";

    if (!run_statement(sql, &db, &stmt))
        goto exit;

    {
        int res = sqlite3_step(stmt);
        while (res == SQLITE_ROW) {
            Folder f;
            f.id = sqlite3_column_string(stmt, 0, "-1");
            f.name = sqlite3_column_string(stmt, 1, "");
            folders.emplace_back(f);
            res = sqlite3_step(stmt);
        }
        if (res != SQLITE_DONE) {
            std::cerr << "Error reading rows: " << sqlite3_errmsg(db) << std::endl;
        }
    }

    exit:
    sqlite3_close(db);
    return folders;
}
示例#2
0
CShellFolderPtr GetShellFolderItem(const FolderList& folder_list, size_t index)
{
	if (index < folder_list.size())
	{
		FolderList::const_iterator it= folder_list.begin();
		advance(it, index);
		return *it;
	}
	ASSERT(false);
	return CShellFolderPtr();
}
示例#3
0
status_t
Protocol::GetFolders(FolderList& folders, BString& separator)
{
	StringList allFolders;
	status_t status = _GetAllFolders(allFolders);
	if (status != B_OK)
		return status;

	StringList subscribedFolders;
	status = GetSubscribedFolders(subscribedFolders, separator);
	if (status != B_OK)
		return status;

	for (size_t i = 0; i < allFolders.size(); i++) {
		FolderEntry entry;
		entry.folder = allFolders[i];
		for (unsigned int a = 0; a < subscribedFolders.size(); a++) {
			if (allFolders[i] == subscribedFolders[a]
				|| allFolders[i].ICompare("INBOX") == 0) {
				entry.subscribed = true;
				break;
			}
		}
		folders.push_back(entry);
	}

	// you could be subscribed to a folder which not exist currently, add them:
	for (size_t a = 0; a < subscribedFolders.size(); a++) {
		bool isInlist = false;
		for (size_t i = 0; i < allFolders.size(); i++) {
			if (subscribedFolders[a] == allFolders[i]) {
				isInlist = true;
				break;
			}
		}
		if (isInlist)
			continue;

		FolderEntry entry;
		entry.folder = subscribedFolders[a];
		entry.subscribed = true;
		folders.push_back(entry);
	}

	return B_OK;
}
示例#4
0
status_t
IMAPFolders::GetFolders(FolderList& folders)
{
	StringList allFolders;
	status_t status = _GetAllFolders(allFolders);
	if (status != B_OK)
		return status;
	StringList subscribedFolders;
	status = _GetSubscribedFolders(subscribedFolders);
	if (status != B_OK)
		return status;

	for (unsigned int i = 0; i < allFolders.size(); i++) {
		FolderInfo info;
		info.folder = allFolders[i];
		for (unsigned int a = 0; a < subscribedFolders.size(); a++) {
			if (allFolders[i] == subscribedFolders[a]
				|| allFolders[i].ICompare("INBOX") == 0) {
				info.subscribed = true;
				break;
			}
		}
		folders.push_back(info);
	}

	// you could be subscribed to a folder which not exist currently, add them:
	for (unsigned int a = 0; a < subscribedFolders.size(); a++) {
		bool isInlist = false;
		for (unsigned int i = 0; i < allFolders.size(); i++) {
			if (subscribedFolders[a] == allFolders[i]) {
				isInlist = true;
				break;
			}
		}
		if (isInlist)
			continue;

		FolderInfo info;
		info.folder = subscribedFolders[a];
		info.subscribed = true;
		folders.push_back(info);
	}

	return B_OK;
}