Esempio n. 1
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;
}
Esempio n. 2
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;
}