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);
}
Exemplo n.º 2
0
TEST(BookmarkTest,UpdateNotifications)
{
	CBookmarkFolder BookmarkFolderParent = CBookmarkFolder::Create(L"Test");

	CTestBookmarkItemNotifier *ptbn = new CTestBookmarkItemNotifier();
	CBookmarkItemNotifier::GetInstance().AddObserver(ptbn);

	CBookmark Bookmark(L"Test name",L"Test location",L"Test description");
	BookmarkFolderParent.InsertBookmark(Bookmark);

	Bookmark.SetName(L"New test folder name");
}
Exemplo n.º 3
0
TEST(BookmarkTest,BookmarkChild)
{
	CBookmarkFolder BookmarkFolderParent = CBookmarkFolder::Create(L"Test");
	CBookmark Bookmark(L"Test name",L"Test location",L"Test description");

	BookmarkFolderParent.InsertBookmark(Bookmark);

	EXPECT_EQ(false,BookmarkFolderParent.HasChildFolder());

	auto itr = BookmarkFolderParent.begin();

	CBookmark ChildBookmark = boost::get<CBookmark>(*itr);

	EXPECT_EQ(Bookmark.GetName(),ChildBookmark.GetName());
	EXPECT_EQ(Bookmark.GetLocation(),ChildBookmark.GetLocation());
	EXPECT_EQ(Bookmark.GetDescription(),ChildBookmark.GetDescription());
}