void CIPBookmarkObserver::BookmarkItemAdded(void *pData,bool bFolder)
{
	IPBookmarkAddedNotification_t *pipban = reinterpret_cast<IPBookmarkAddedNotification_t *>(pData);

	/* TODO: Find the parent with the specified GUID. */
	//pipban->guidParent
	CBookmarkFolder *pParentBookmarkFolder = m_pAllBookmarks;

	m_pipbns->SetIPBroadcast(false);

	char *pSerializedData = reinterpret_cast<char *>(pData) + sizeof(IPBookmarkAddedNotification_t);

	try
	{
		if(bFolder)
		{
			CBookmarkFolder BookmarkFolder = CBookmarkFolder::Unserialize(pSerializedData);
			pParentBookmarkFolder->InsertBookmarkFolder(BookmarkFolder,pipban->uPosition);
		}
		else
		{
			CBookmark Bookmark(pSerializedData);
			pParentBookmarkFolder->InsertBookmark(Bookmark,pipban->uPosition);
		}
	}
	catch(int)
	{
		/* The actual content of the error here
		is unimportant. May be needed in the
		future if an error message will be shown
		to the user. */
	}

	m_pipbns->SetIPBroadcast(true);
}
Ejemplo n.º 2
0
TEST(BookmarkTest,BookmarkFolderChild)
{
	CBookmarkFolder BookmarkFolderParent = CBookmarkFolder::Create(L"Test");
	CBookmarkFolder BookmarkFolder = CBookmarkFolder::Create(L"Test name");

	BookmarkFolderParent.InsertBookmarkFolder(BookmarkFolder);

	ASSERT_EQ(true,BookmarkFolderParent.HasChildFolder());

	auto itr = BookmarkFolderParent.begin();

	CBookmarkFolder ChildBookmarkFolder = boost::get<CBookmarkFolder>(*itr);

	EXPECT_EQ(BookmarkFolder.GetName(),ChildBookmarkFolder.GetName());
}