Closed
Bug 437576
Opened 17 years ago
Closed 17 years ago
Cannot access the bookmarkservice (nsINavBookmarksService) in C++
Categories
(Firefox :: Bookmarks & History, defect)
Tracking
()
RESOLVED
INCOMPLETE
People
(Reporter: loredan_cuc, Unassigned)
Details
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9) Gecko/2008052906 Firefox/3.0
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9) Gecko/2008052906 Firefox/3.0
I want to write an C++ console application in VS2005 to use the new Bookmarks API (nsINavBookmarksService) for Firefox 3. I got the latest nightly Gecko (xulrunner) sdk (xulrunner-1.9pre.en-US.win32.sdk.zip). My problem is that I cannot get the service. I initialized the Glue and the XPCOM, I got the ServiceManager but I cannot get the service through nsIServiceManager::GetServiceByContractID nor by nsIServiceManager::GetService (I get NS_ERROR_UNEXPECTED). I also checked the xpti.dat and compreg.dat files and the component/service is there. I also tried accessing another service (ICacheService) and it worked, so the code seems to be correct, but still the bookmarks-service cannot be retrieved.
Reproducible: Always
Steps to Reproduce:
1. Initialize Glue and XPCOM
2. Get the service manager
3. Get the Bookmarks service
Actual Results:
When trying to get the bookmarks service and error is returned (NS_ERROR_UNEXPECTED) and the bookmarks service is unavailable.
Expected Results:
The Bookmarks service is returned without any errors and the bookmarks service can be used.
sample of the code I was using.
...
nsresult GetBookmarksService()
{
nsresult rv;
nsCOMPtr<nsIServiceManager> servMan;
rv = NS_GetServiceManager(getter_AddRefs(servMan));
if (NS_FAILED(rv))
{
return -1;
}
nsCOMPtr<nsIComponentManager> compMan;
rv = NS_GetComponentManager(getter_AddRefs(compMan));
if (NS_FAILED(rv))
{
return -1;
}
nsCOMPtr<nsINavBookmarksService> bookmarksService;
rv = servMan->GetServiceByContractID(NS_NAVBOOKMARKSSERVICE_CONTRACTID, NS_GET_IID(nsINavBookmarksService), getter_AddRefs(bookmarksService));
if (NS_FAILED(rv))
{
//NS_ERROR_UNEXPECTED
printf("ERROR: Cannot retrieve the service [%x].\n", rv);
}
rv = compMan->CreateInstanceByContractID(NS_NAVBOOKMARKSSERVICE_CONTRACTID, nsnull, NS_GET_IID(nsINavBookmarksService), getter_AddRefs(bookmarksService));
if (NS_FAILED(rv))
{
//NS_ERROR_UNEXPECTED
printf("ERROR: Cannot retrieve the service [%x].\n", rv);
}
// nsCOMPtr<nsICacheService> cacheService;
// rv = servMan->GetServiceByContractID(NS_CACHESERVICE_CONTRACTID, NS_GET_IID(nsICacheService), getter_AddRefs(cacheService));
// if (NS_FAILED(rv))
// return false;
nsIID nsiid = NS_INAVBOOKMARKSSERVICE_IID;
nsCID nscid = NS_NAVBOOKMARKSSERVICE_CID;
rv = servMan->GetService(nscid, nsiid, (void **)&bookmarksService);
if (NS_FAILED(rv))
{
//NS_ERROR_UNEXPECTED
printf("ERROR: Cannot retrieve the service [%x].\n", rv);
}
rv = compMan->GetClassObjectByContractID(NS_NAVBOOKMARKSSERVICE_CONTRACTID, NS_GET_IID(nsINavBookmarksService), getter_AddRefs(bookmarksService));
if (NS_FAILED(rv))
{
//NS_ERROR_UNEXPECTED
printf("ERROR: Cannot retrieve the service [%x].\n", rv);
}
rv = compMan->GetClassObject(nscid, nsiid, getter_AddRefs(bookmarksService));
if (NS_FAILED(rv))
{
//NS_ERROR_UNEXPECTED
printf("ERROR: Cannot retrieve the service [%x].\n", rv);
}
rv = NS_ShutdownXPCOM(servMan);
return rv;
}
int _tmain(int argc, _TCHAR* argv[])
{
nsresult rv;
rv = XPCOMGlueStartup("C:\\Program Files\\Mozilla Firefox\\xpcom.dll");
rv = GetBookmarksService();
rv = XPCOMGlueShutdown();
return rv;
}
| Reporter | ||
Updated•17 years ago
|
Severity: normal → major
Flags: blocking-firefox3?
Version: unspecified → Trunk
Comment 1•17 years ago
|
||
Unconfirmed bugs can't block.
--> Firefox::Places
Component: Bookmarks → Places
Flags: blocking-firefox3?
QA Contact: bookmarks → places
Comment 2•17 years ago
|
||
Bulk closing all UNCONFIRMED bugs dealing with places that haven't had any bug activity in over 120 days, have no votes, and are not enhancement requests.
If you are still experiencing this issue in Firefox 3.0 or later, please re-open the bug with steps to reproduce (if they were not part of the original comment).
Status: UNCONFIRMED → RESOLVED
Closed: 17 years ago
Resolution: --- → INCOMPLETE
Comment 3•16 years ago
|
||
Bug 451915 - move Firefox/Places bugs to Firefox/Bookmarks and History. Remove all bugspam from this move by filtering for the string "places-to-b-and-h".
In Thunderbird 3.0b, you do that as follows:
Tools | Message Filters
Make sure the correct account is selected. Click "New"
Conditions: Body contains places-to-b-and-h
Change the action to "Delete Message".
Select "Manually Run" from the dropdown at the top.
Click OK.
Select the filter in the list, make sure "Inbox" is selected at the bottom, and click "Run Now". This should delete all the bugspam. You can then delete the filter.
Gerv
Component: Places → Bookmarks & History
QA Contact: places → bookmarks
You need to log in
before you can comment on or make changes to this bug.
Description
•