Why NS_GetSpecialDirectory fails?

View: New views
10 Messages — Rating Filter:   Alert me  

Why NS_GetSpecialDirectory fails?

by Georgios Petasis-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

Now that I have fixed most memory leaks, I am after other issues :-)
My embedded app fails to keep navigation history, and tracing down the
code there is a problem in
nsNavHistory::InitDBFile(), where the call to:

NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, ...);

fails (with result 0x80004005 - which means what?).

Any ideas why this call fails? I had the impression that returns
something related to the second argument (AppDir)
of  XRE_InitEmbeding().

Also, what I am supposed to pass as an application directory to
XRE_InitEmbeding? My ~/.mozilla directory?

Regards,

George
_______________________________________________
dev-embedding mailing list
dev-embedding@...
https://lists.mozilla.org/listinfo/dev-embedding

Parent Message unknown Re: Why NS_GetSpecialDirectory fails?

by Benjamin Smedberg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 11/5/09 6:35 PM, Georgios Petasis wrote:

> Hi all,
>
> Now that I have fixed most memory leaks, I am after other issues :-)
> My embedded app fails to keep navigation history, and tracing down the
> code there is a problem in
> nsNavHistory::InitDBFile(), where the call to:
>
> NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, ...);
>
> fails (with result 0x80004005 - which means what?).
>
> Any ideas why this call fails? I had the impression that returns
> something related to the second argument (AppDir)
> of  XRE_InitEmbeding().

Not at all. The AppDir passed to XRE_InitEmbedding is the location of your
application files, typically something like c:\Program Files\Firefox. I
thought the comment in the header made this clear:

329  * @param aAppDirectory      The directory in which the application
components
330  *                           and resources can be found. This will map to
331  *                           the NS_OS_CURRENT_PROCESS_DIR directory service
332  *                           key.

The profile directory is where user-specific data is stored. It is typically
something like ~/.vendor/appname
(C:\Users\foo\AppData\Mozilla\Firefox\Profiles\profilename.random for Firefox).

Please read the comment in nsXULAppAPI.h for the XRE_NotifyProfile function
which explains how you should set up a profile.

--BDS
_______________________________________________
dev-embedding mailing list
dev-embedding@...
https://lists.mozilla.org/listinfo/dev-embedding

Re: Why NS_GetSpecialDirectory fails?

by Georgios Petasis-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

O/H Benjamin Smedberg ??????:

> On 11/5/09 6:35 PM, Georgios Petasis wrote:
>  
>> Hi all,
>>
>> Now that I have fixed most memory leaks, I am after other issues :-)
>> My embedded app fails to keep navigation history, and tracing down the
>> code there is a problem in
>> nsNavHistory::InitDBFile(), where the call to:
>>
>> NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, ...);
>>
>> fails (with result 0x80004005 - which means what?).
>>
>> Any ideas why this call fails? I had the impression that returns
>> something related to the second argument (AppDir)
>> of  XRE_InitEmbeding().
>>    
>
> Not at all. The AppDir passed to XRE_InitEmbedding is the location of your
> application files, typically something like c:\Program Files\Firefox. I
> thought the comment in the header made this clear:
>
> 329  * @param aAppDirectory      The directory in which the application
> components
> 330  *                           and resources can be found. This will map to
> 331  *                           the NS_OS_CURRENT_PROCESS_DIR directory service
> 332  *                           key.
>
> The profile directory is where user-specific data is stored. It is typically
> something like ~/.vendor/appname
> (C:\Users\foo\AppData\Mozilla\Firefox\Profiles\profilename.random for Firefox).
>
> Please read the comment in nsXULAppAPI.h for the XRE_NotifyProfile function
> which explains how you should set up a profile.
>
> --BDS
> _______________________________________________
> dev-embedding mailing list
> dev-embedding@...
> https://lists.mozilla.org/listinfo/dev-embedding
>
>  
I have tried many values for aAppDirectory, including the directory
firefox is, but I get the same failure.
I think that the problem may be the fact that I don't provide a
directory provider in XRE_InitEmbeding (its 3rd argument).
I will try to provide one and see if it helps...

George
_______________________________________________
dev-embedding mailing list
dev-embedding@...
https://lists.mozilla.org/listinfo/dev-embedding

Parent Message unknown Re: Why NS_GetSpecialDirectory fails?

by Benjamin Smedberg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 11/6/09 9:27 AM, Georgios Petasis wrote:

> I have tried many values for aAppDirectory, including the directory
> firefox is, but I get the same failure.

Which failure? The failure where you can't get a profile directory? Of
course you get that failure, because aAppDirectory has nothing to do with
the profile directory.

> I think that the problem may be the fact that I don't provide a
> directory provider in XRE_InitEmbeding (its 3rd argument).
> I will try to provide one and see if it helps...

Yes, you cannot have a profile directory unless you implement a directory
provider.

--BDS

_______________________________________________
dev-embedding mailing list
dev-embedding@...
https://lists.mozilla.org/listinfo/dev-embedding

Re: Why NS_GetSpecialDirectory fails?

by Georgios Petasis-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

O/H Benjamin Smedberg ??????:

> On 11/6/09 9:27 AM, Georgios Petasis wrote:
>
>  
>> I have tried many values for aAppDirectory, including the directory
>> firefox is, but I get the same failure.
>>    
>
> Which failure? The failure where you can't get a profile directory? Of
> course you get that failure, because aAppDirectory has nothing to do with
> the profile directory.
>  
Dear Benjamin,

I am getting a failure with navigation history, as there is a failure in
nsNavHistory::InitDBFile().

Regards,

George
_______________________________________________
dev-embedding mailing list
dev-embedding@...
https://lists.mozilla.org/listinfo/dev-embedding

Parent Message unknown Re: Why NS_GetSpecialDirectory fails?

by Benjamin Smedberg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 11/6/09 9:58 AM, Georgios Petasis wrote:

> O/H Benjamin Smedberg ??????:
>> On 11/6/09 9:27 AM, Georgios Petasis wrote:
>>
>>  
>>> I have tried many values for aAppDirectory, including the directory
>>> firefox is, but I get the same failure.
>>>    
>>
>> Which failure? The failure where you can't get a profile directory? Of
>> course you get that failure, because aAppDirectory has nothing to do with
>> the profile directory.
>>  
> Dear Benjamin,
>
> I am getting a failure with navigation history, as there is a failure in
> nsNavHistory::InitDBFile().

Yes. This is entirely expected. You don't have a profile, and therefor
nsNavHistory has no place to save the history data. You will continue to
have this error until you follow the instructions in nsXULAppAPI.h and set
up a profile using XRE_LockProfile, a directory provider passed to
XRE_InitEmbedding, and XRE_NotifyProfile.

--BDS
_______________________________________________
dev-embedding mailing list
dev-embedding@...
https://lists.mozilla.org/listinfo/dev-embedding

Re: Why NS_GetSpecialDirectory fails?

by Georgios Petasis-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

O/H Benjamin Smedberg ??????:

> On 11/5/09 6:35 PM, Georgios Petasis wrote:
>  
>> Hi all,
>>
>> Now that I have fixed most memory leaks, I am after other issues :-)
>> My embedded app fails to keep navigation history, and tracing down the
>> code there is a problem in
>> nsNavHistory::InitDBFile(), where the call to:
>>
>> NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, ...);
>>
>> fails (with result 0x80004005 - which means what?).
>>
>> Any ideas why this call fails? I had the impression that returns
>> something related to the second argument (AppDir)
>> of  XRE_InitEmbeding().
>>    
>
> Not at all. The AppDir passed to XRE_InitEmbedding is the location of your
> application files, typically something like c:\Program Files\Firefox. I
> thought the comment in the header made this clear:
>
> 329  * @param aAppDirectory      The directory in which the application
> components
> 330  *                           and resources can be found. This will map to
> 331  *                           the NS_OS_CURRENT_PROCESS_DIR directory service
> 332  *                           key.
>
> The profile directory is where user-specific data is stored. It is typically
> something like ~/.vendor/appname
> (C:\Users\foo\AppData\Mozilla\Firefox\Profiles\profilename.random for Firefox).
>
> Please read the comment in nsXULAppAPI.h for the XRE_NotifyProfile function
> which explains how you should set up a profile.
>
> --BDS
> _______________________________________________
> dev-embedding mailing list
> dev-embedding@...
> https://lists.mozilla.org/listinfo/dev-embedding
>
>  
I read the info in nsXULAppAPI.h and I tried to write a directory
provider based on the gtk one.
But I haven't got it right, the problem still exists. Is there a default
implementation I can use, or is anybody willing to share a working
provider for linux?

DOes anybody knows where I can find the default provider for firefox in
the sources?

Regards,

George
_______________________________________________
dev-embedding mailing list
dev-embedding@...
https://lists.mozilla.org/listinfo/dev-embedding

Re: Why NS_GetSpecialDirectory fails?

by Georgios Petasis-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

O/H Georgios Petasis ??????:

> O/H Benjamin Smedberg ??????:
>> On 11/5/09 6:35 PM, Georgios Petasis wrote:
>>  
>>> Hi all,
>>>
>>> Now that I have fixed most memory leaks, I am after other issues :-)
>>> My embedded app fails to keep navigation history, and tracing down the
>>> code there is a problem in
>>> nsNavHistory::InitDBFile(), where the call to:
>>>
>>> NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, ...);
>>>
>>> fails (with result 0x80004005 - which means what?).
>>>
>>> Any ideas why this call fails? I had the impression that returns
>>> something related to the second argument (AppDir)
>>> of  XRE_InitEmbeding().
>>>    
>>
>> Not at all. The AppDir passed to XRE_InitEmbedding is the location of your
>> application files, typically something like c:\Program Files\Firefox. I
>> thought the comment in the header made this clear:
>>
>> 329  * @param aAppDirectory      The directory in which the application
>> components
>> 330  *                           and resources can be found. This will map to
>> 331  *                           the NS_OS_CURRENT_PROCESS_DIR directory service
>> 332  *                           key.
>>
>> The profile directory is where user-specific data is stored. It is typically
>> something like ~/.vendor/appname
>> (C:\Users\foo\AppData\Mozilla\Firefox\Profiles\profilename.random for Firefox).
>>
>> Please read the comment in nsXULAppAPI.h for the XRE_NotifyProfile function
>> which explains how you should set up a profile.
>>
>> --BDS
>> _______________________________________________
>> dev-embedding mailing list
>> dev-embedding@...
>> https://lists.mozilla.org/listinfo/dev-embedding
>>
>>  
> I read the info in nsXULAppAPI.h and I tried to write a directory
> provider based on the gtk one.
> But I haven't got it right, the problem still exists. Is there a
> default implementation I can use, or is anybody willing to share a
> working provider for linux?
>
> DOes anybody knows where I can find the default provider for firefox
> in the sources?
>
> Regards,
>
> George
I have found some code in profile/dirserviceprovider, where an
implementation of nsProfileDirServiceProvider exists. There is also a
function to get an instance of such a class
(NS_NewProfileDirServiceProvider()).

Do you think that this is something I can use in my code?
For example doing something like:

<nsCOMPtr<nsIDirectoryServiceProvider> dsp;
NS_NewProfileDirServiceProvider(getter_AddRefs(dsp));
XRE_InitEmbeding(..., ..., dsp, nsnul, nsnull);

Regards,

George
_______________________________________________
dev-embedding mailing list
dev-embedding@...
https://lists.mozilla.org/listinfo/dev-embedding

Re: Why NS_GetSpecialDirectory fails?

by Georgios Petasis-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

O/H Georgios Petasis έγραψε:

> O/H Georgios Petasis ??????:
>> O/H Benjamin Smedberg ??????:
>>> On 11/5/09 6:35 PM, Georgios Petasis wrote:
>>>> Hi all,
>>>>
>>>> Now that I have fixed most memory leaks, I am after other issues :-)
>>>> My embedded app fails to keep navigation history, and tracing down the
>>>> code there is a problem in
>>>> nsNavHistory::InitDBFile(), where the call to:
>>>>
>>>> NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, ...);
>>>>
>>>> fails (with result 0x80004005 - which means what?).
>>>>
>>>> Any ideas why this call fails? I had the impression that returns
>>>> something related to the second argument (AppDir)
>>>> of XRE_InitEmbeding().
>>>
>>> Not at all. The AppDir passed to XRE_InitEmbedding is the location
>>> of your
>>> application files, typically something like c:\Program Files\Firefox. I
>>> thought the comment in the header made this clear:
>>>
>>> 329 * @param aAppDirectory The directory in which the application
>>> components
>>> 330 * and resources can be found. This will map to
>>> 331 * the NS_OS_CURRENT_PROCESS_DIR directory service
>>> 332 * key.
>>>
>>> The profile directory is where user-specific data is stored. It is
>>> typically
>>> something like ~/.vendor/appname
>>> (C:\Users\foo\AppData\Mozilla\Firefox\Profiles\profilename.random
>>> for Firefox).
>>>
>>> Please read the comment in nsXULAppAPI.h for the XRE_NotifyProfile
>>> function
>>> which explains how you should set up a profile.
>>>
>>> --BDS
>>> _______________________________________________
>>> dev-embedding mailing list
>>> dev-embedding@...
>>> https://lists.mozilla.org/listinfo/dev-embedding
>>>
>> I read the info in nsXULAppAPI.h and I tried to write a directory
>> provider based on the gtk one.
>> But I haven't got it right, the problem still exists. Is there a
>> default implementation I can use, or is anybody willing to share a
>> working provider for linux?
>>
>> DOes anybody knows where I can find the default provider for firefox
>> in the sources?
>>
>> Regards,
>>
>> George
> I have found some code in profile/dirserviceprovider, where an
> implementation of nsProfileDirServiceProvider exists. There is also a
> function to get an instance of such a class
> (NS_NewProfileDirServiceProvider()).
>
> Do you think that this is something I can use in my code?
> For example doing something like:
>
> <nsCOMPtr<nsIDirectoryServiceProvider> dsp;
> NS_NewProfileDirServiceProvider(getter_AddRefs(dsp));
> XRE_InitEmbeding(..., ..., dsp, nsnul, nsnull);
>
> Regards,
>
> George
> _______________________________________________
> dev-embedding mailing list
> dev-embedding@...
> https://lists.mozilla.org/listinfo/dev-embedding
>
It seems that I cannot use it. I get linker errors. The function is not
in the libraries I am supposed to link to...

George
_______________________________________________
dev-embedding mailing list
dev-embedding@...
https://lists.mozilla.org/listinfo/dev-embedding

Re: Why NS_GetSpecialDirectory fails?

by Georgios Petasis-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

O/H Georgios Petasis έγραψε:

> O/H Georgios Petasis έγραψε:
>> O/H Georgios Petasis ??????:
>>> O/H Benjamin Smedberg ??????:
>>>> On 11/5/09 6:35 PM, Georgios Petasis wrote:
>>>>> Hi all,
>>>>>
>>>>> Now that I have fixed most memory leaks, I am after other issues :-)
>>>>> My embedded app fails to keep navigation history, and tracing down
>>>>> the
>>>>> code there is a problem in
>>>>> nsNavHistory::InitDBFile(), where the call to:
>>>>>
>>>>> NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, ...);
>>>>>
>>>>> fails (with result 0x80004005 - which means what?).
>>>>>
>>>>> Any ideas why this call fails? I had the impression that returns
>>>>> something related to the second argument (AppDir)
>>>>> of XRE_InitEmbeding().
>>>>
>>>> Not at all. The AppDir passed to XRE_InitEmbedding is the location
>>>> of your
>>>> application files, typically something like c:\Program
>>>> Files\Firefox. I
>>>> thought the comment in the header made this clear:
>>>>
>>>> 329 * @param aAppDirectory The directory in which the application
>>>> components
>>>> 330 * and resources can be found. This will map to
>>>> 331 * the NS_OS_CURRENT_PROCESS_DIR directory service
>>>> 332 * key.
>>>>
>>>> The profile directory is where user-specific data is stored. It is
>>>> typically
>>>> something like ~/.vendor/appname
>>>> (C:\Users\foo\AppData\Mozilla\Firefox\Profiles\profilename.random
>>>> for Firefox).
>>>>
>>>> Please read the comment in nsXULAppAPI.h for the XRE_NotifyProfile
>>>> function
>>>> which explains how you should set up a profile.
>>>>
>>>> --BDS
>>>> _______________________________________________
>>>> dev-embedding mailing list
>>>> dev-embedding@...
>>>> https://lists.mozilla.org/listinfo/dev-embedding
>>>>
>>> I read the info in nsXULAppAPI.h and I tried to write a directory
>>> provider based on the gtk one.
>>> But I haven't got it right, the problem still exists. Is there a
>>> default implementation I can use, or is anybody willing to share a
>>> working provider for linux?
>>>
>>> DOes anybody knows where I can find the default provider for firefox
>>> in the sources?
>>>
>>> Regards,
>>>
>>> George
>> I have found some code in profile/dirserviceprovider, where an
>> implementation of nsProfileDirServiceProvider exists. There is also a
>> function to get an instance of such a class
>> (NS_NewProfileDirServiceProvider()).
>>
>> Do you think that this is something I can use in my code?
>> For example doing something like:
>>
>> <nsCOMPtr<nsIDirectoryServiceProvider> dsp;
>> NS_NewProfileDirServiceProvider(getter_AddRefs(dsp));
>> XRE_InitEmbeding(..., ..., dsp, nsnul, nsnull);
>>
>> Regards,
>>
>> George
>> _______________________________________________
>> dev-embedding mailing list
>> dev-embedding@...
>> https://lists.mozilla.org/listinfo/dev-embedding
>>
> It seems that I cannot use it. I get linker errors. The function is
> not in the libraries I am supposed to link to...
>
> George
>

I managed to get it link (by copying the nsProfileDirServiceProvider.cpp
in my code), but now I get a crash.
My code now looks like this (variable profileDir holds
/home/user/.app_profile):

haveProfile = profileDir.length() > 0;
  if (haveProfile) {
    NS_ConvertUTF8toUTF16 profile_dir(profileDir.c_str());
    result = NS_NewLocalFile(profile_dir, PR_TRUE,
getter_AddRefs(mProfileDir));
    if (NS_FAILED(result)) haveProfile = false;
    result = NS_NewProfileDirServiceProvider(PR_FALSE,
                                             
getter_AddRefs(dirServiceProvider));
    if (NS_FAILED(result)) haveProfile = false;
    if (haveProfile && dirServiceProvider) {
      dirServiceProvider->SetProfileDir(mProfileDir);
      TkGecko_XRE_LockProfileDirectory(mProfileDir,
getter_AddRefs(mProfileLock));
    } else {
      haveProfile = false;
    }
  }

  /* Call XRE_InitEmbedding... */
  result = TkGecko_XRE_InitEmbedding(mXulDir, appDir.length() ? mAppDir : 0,
                                     haveProfile ? dirServiceProvider   : 0,
                                     0, 0);
  if (NS_FAILED(result)) return result;
 
  /* Call TkGecko_XRE_NotifyProfile... */
  if (haveProfile) {
    TkGecko_XRE_NotifyProfile();
  }

When haveProfile is false (i.e. profileDir is the empty string),
everything runs normal (but without navigation).
If it is true, a crash happens:

0x029207a5 in nsWebBrowser::BindListener (this=0xb7edf848,
    aListener=0xb7ed707c, aIID=@0x2bdaa6c) at nsWebBrowser.cpp:275
275             rv = mWebProgress->AddProgressListener(listener,
nsIWebProgress::NOTIFY_ALL);
Current language:  auto; currently c++
(gdb) where
#0  0x029207a5 in nsWebBrowser::BindListener (this=0xb7edf848,
    aListener=0xb7ed707c, aIID=@0x2bdaa6c) at nsWebBrowser.cpp:275
#1  0x02921064 in nsWebBrowser::Create (this=0xb7edf848)
    at nsWebBrowser.cpp:1184

Any idea why? Actually it does not crash with the debug version of
xulrunner that I have compiled myself, but it does crash if I use the
xulrunner that is installed in my system (Fedora 11, xulrunner-1.9.1).

Why adding a directory provider stops the registration of a progress
listener?

Regards,

George
_______________________________________________
dev-embedding mailing list
dev-embedding@...
https://lists.mozilla.org/listinfo/dev-embedding