Bug 55410 - automatically fill in the default user's name into tools->options->user data
Summary: automatically fill in the default user's name into tools->options->user data
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: framework (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: Other All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: difficultyMedium, easyHack
Depends on:
Blocks: Desktop-Integration Options-Dialog-UserData
  Show dependency treegraph
 
Reported: 2012-09-28 09:32 UTC by Caolán McNamara
Modified: 2020-03-14 19:28 UTC (History)
8 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Caolán McNamara 2012-09-28 09:32:52 UTC
For gnome in shell/source/backends/gconfbe/gconfaccess.cxx we fill in the user's name information from glib's "g_get_real_name" (search for "givenname" and "g_get_real_name" in there.

It would be nice to fill in the defaults under windows as well SHGetUserDisplayName (http://undoc.airesoft.co.uk/shell32.dll/SHGetUserDisplayName.php) looks about right.

In officecfg/registry/data/org/openoffice/UserProfile.xcu there is
  <prop oor:name="givenname" install:module="gconflockdown">
    <value oor:external=
        "com.sun.star.configuration.backend.GconfBackend givenname"/>
  </prop>

which makes the configuration check that module to get that givenname property. If that was changed to...

<prop oor:name="givenname">
 <value install:module="unixdesktop" oor:external=
   "com.sun.star.configuration.backend.GconfBackend givenname"/>
  <value install:module="unixdesktop" oor:external=
   "com.sun.star.configuration.backend.WinInetBackend givenname"/>
</prop>

then it would also ask the windows backend in shell/source/backends/wininetbe/wininetbackend.cxx through WinInetBackend::getPropertyValue for "givenname" and some attempt to use SHGetUserDisplayName there might get us a fairly useful default value
Comment 1 Urmas 2012-09-28 20:40:52 UTC
Ordinal-exported functions are NEVER right.
Comment 2 Björn Michaelsen 2013-10-04 18:46:49 UTC
adding LibreOffice developer list as CC to unresolved EasyHacks for better visibility.

see e.g. http://nabble.documentfoundation.org/minutes-of-ESC-call-td4076214.html for details
Comment 3 Robinson Tryon (qubit) 2013-10-23 16:45:03 UTC Comment hidden (obsolete)
Comment 4 How can I remove my account? 2014-05-23 08:44:23 UTC
That SHGetUserDisplayName() seems to be undocumented, so we definitely should *not* use that. Which is what Urmas meant, I guess.
Comment 5 Harpreet Bansal 2015-02-12 13:52:59 UTC
I think GetUserNameEx should do the trick for windows 

https://msdn.microsoft.com/en-us/library/ms724435%28VS.85%29.aspx
Comment 6 Brent Ritzema 2015-04-05 22:41:56 UTC
I am attempting to add the default entry in on windows, however I am having trouble with this.

Main affected file: shell/source/backends/desktopbe/desktopbackend.cxx

Currently I am trying to set the value manually in desktopbackend.cxx. I am doing this by returning the value "brent" in the Default::getPropertyValue function. Since the officecfg/registry/data/org/openoffice/UserProfile.xcu has this:
<prop oor:name="givenname">
      <value install:module="unixdesktop" oor:external="com.sun.star.configuration.backend.DesktopBackend givenname"/>
</prop>

I figured that it would call getPropertyValue to get the "givenname" value. Since it would call getPropertyValue, the function should return "brent". This would then automatically fill in the tools->options->user data name value correct? However it does not seem to fill it in.

Oh and before I did this I recompiled the shell, officecfg, and postprocess modules (shell contained the backend) so that these changes may take affect. Then I ran LibreOffice.



I was wondering if this was because the program no longer checks for default values using the UserProfile.xcu file or if there was another reason. Either way the value is not appearing within the box.

Should I try re-making the whole program instead of just the few affected modules? Am I missing something?
Comment 7 Caolán McNamara 2015-04-07 09:01:41 UTC
This is probably only called on first-start so rm -rf instdir/user and restart LibreOffice should retrigger "first-start"
Comment 8 Stephan Bergmann 2015-04-07 09:07:23 UTC
(In reply to ritztro from comment #6)
> Currently I am trying to set the value manually in desktopbackend.cxx. I am
> doing this by returning the value "brent" in the Default::getPropertyValue
> function. Since the officecfg/registry/data/org/openoffice/UserProfile.xcu
> has this:
> <prop oor:name="givenname">
>       <value install:module="unixdesktop"
> oor:external="com.sun.star.configuration.backend.DesktopBackend givenname"/>
> </prop>

The install:module="unixdesktop" attribute means that this oor:external value will only be used on Unix (Linux), not on Windows.  Something like

> diff --git a/officecfg/Configuration_officecfg.mk b/officecfg/Configuration_officecfg.mk
> index 7e2af03..b7e8625 100644
> --- a/officecfg/Configuration_officecfg.mk
> +++ b/officecfg/Configuration_officecfg.mk
> @@ -69,6 +69,7 @@ $(eval $(call gb_Configuration_add_spool_modules,registry,officecfg/registry/dat
>         org/openoffice/Setup-reportbuilder.xcu \
>         org/openoffice/Setup-start.xcu \
>         org/openoffice/UserProfile-unixdesktop.xcu \
> +       org/openoffice/UserProfile-unxwnt.xcu \
>         org/openoffice/VCL-gconflockdown.xcu \
>         org/openoffice/VCL-unixdesktop.xcu \
>         org/openoffice/Office/Accelerators-macosx.xcu \
> diff --git a/officecfg/registry/data/org/openoffice/UserProfile.xcu b/officecfg/registry/data/org/openoffice/UserProfile.xcu
> index b41756a..c206366 100644
> --- a/officecfg/registry/data/org/openoffice/UserProfile.xcu
> +++ b/officecfg/registry/data/org/openoffice/UserProfile.xcu
> @@ -20,7 +20,7 @@
>  <oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:install="http://openoffice.org/2004/installation" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" oor:name="UserProfile" oor:package="org.openoffice">
>    <node oor:name="Data">
>      <prop oor:name="givenname">
> -      <value install:module="unixdesktop" oor:external="com.sun.star.configuration.backend.DesktopBackend givenname"/>
> +      <value install:module="unxwnt" oor:external="com.sun.star.configuration.backend.DesktopBackend givenname"/>
>      </prop>
>      <prop oor:name="sn">
>        <value install:module="unixdesktop" oor:external="com.sun.star.configuration.backend.DesktopBackend sn"/>
> diff --git a/postprocess/CustomTarget_registry.mk b/postprocess/CustomTarget_registry.mk
> index a568832..f10c18b 100644
> --- a/postprocess/CustomTarget_registry.mk
> +++ b/postprocess/CustomTarget_registry.mk
> @@ -312,6 +312,7 @@ postprocess_FILES_main += \
>         $(postprocess_MOD)/org/openoffice/Office/Paths-unixdesktop.xcu \
>         $(postprocess_MOD)/org/openoffice/Office/Paths-unxwnt.xcu \
>         $(postprocess_MOD)/org/openoffice/UserProfile-unixdesktop.xcu \
> +       $(postprocess_MOD)/org/openoffice/UserProfile-unxwnt.xcu \
>         $(postprocess_MOD)/org/openoffice/VCL-unixdesktop.xcu
>                 # Inet-unixdesktop.xcu must come after Inet.xcu
>                 # VCL-unixdesktop.xcu must come after VCL.xcu
> @@ -322,6 +323,7 @@ postprocess_FILES_main += \
>         $(postprocess_MOD)/org/openoffice/Office/Accelerators-unxwnt.xcu \
>         $(postprocess_MOD)/org/openoffice/Office/Common-wnt.xcu \
>         $(postprocess_MOD)/org/openoffice/Office/Paths-unxwnt.xcu \
> +       $(postprocess_MOD)/org/openoffice/UserProfile-unxwnt.xcu \
>         $(postprocess_MOD)/org/openoffice/ucb/Configuration-win.xcu
>                 # Inet-wnt.xcu must come after Inet.xcu
>  postprocess_DRIVERS += ado

(and rebuilding at least officecfg and postprocess) should make your changes work.
Comment 9 Brent Ritzema 2015-04-08 01:30:03 UTC
Alright well I made that change to UserProfile.xcu... However it still is not working. Maybe I am doing something wrong in desktopbackend.cxx? Here is what I did just as a quick test:

css::uno::Any Default::getPropertyValue(OUString const & PropertyName)
    throw (
        css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
        css::uno::RuntimeException, std::exception)
{
    //Added these next 5 lines
    if ( PropertyName == "givenname")
    {
        css::uno::Any value = "brent";
        return css::uno::makeAny(value);
    }
    if ( PropertyName == "EnableATToolSupport" ||
         PropertyName == "ExternalMailer" ||
         PropertyName == "SourceViewFontHeight" ||
         PropertyName == "SourceViewFontName" ||
         PropertyName == "TemplatePathVariable" ||
         PropertyName == "WorkPathVariable" ||
         PropertyName == "ooInetFTPProxyName" ||
         PropertyName == "ooInetFTPProxyPort" ||
         PropertyName == "ooInetHTTPProxyName" ||
         PropertyName == "ooInetHTTPProxyPort" ||
         PropertyName == "ooInetHTTPSProxyName" ||
         PropertyName == "ooInetHTTPSProxyPort" ||
         PropertyName == "ooInetNoProxy" ||
         PropertyName == "ooInetProxyType" ||
         PropertyName == "givenname" ||
         PropertyName == "sn" )
    {
        
        return css::uno::makeAny(css::beans::Optional< css::uno::Any >());
    }
    throw css::beans::UnknownPropertyException(
        PropertyName, static_cast< cppu::OWeakObject * >(this));
}

When I go to the options my name still does not appear (I did delete the user directory every time).

Any more help is appreciated :)
Comment 10 Stephan Bergmann 2015-04-08 08:00:34 UTC
The desktopbe library is currently only built on Linux, see the start of shell/Module_shell.mk:

> $(eval $(call gb_Module_add_targets,shell,\
> 	$(if $(filter-out MACOSX WNT,$(OS)),Library_desktopbe) \
> 	Library_localebe \
> ))
Comment 11 Brent Ritzema 2015-04-09 04:35:02 UTC
Okay so I went onto linux to see if my code would even work first.. And I ended up changing my code to this:

if ( PropertyName == "givenname")
    {
        return css::uno::makeAny(OUString("brent"));
    }
After I deleted the user directory. I then recompiled the shell, officecfg, and postprocess (last two just to be safe). Then when I ran the program the value was still not there. Is there any reason that maybe the system got discontinued somewhere else in the code or am I missing something? Because based off this, if it is requesting the value and will fill in the space with the value given, this should work and show this value.

Any more help is appreciated and has been greatly appreciated thus far (Thanks Caolána and Stephan) :)
Comment 12 Stephan Bergmann 2015-04-09 06:42:25 UTC
See createInstance in shell/source/backends/desktopbe/desktopbackend.cxx.  The code you modified in Default::getPropertyValue would only get used on Linux if your desktop environment did not match one of the more specific overrides of the desktop backend (for GNOME/KDE/KDE4).
Comment 13 Robinson Tryon (qubit) 2015-12-13 10:58:02 UTC Comment hidden (obsolete)
Comment 14 Pranav Ganorkar 2016-02-13 14:39:08 UTC
I want to work on this bug....any leads on how to proceed further ?
Comment 15 Robinson Tryon (qubit) 2016-02-18 14:52:16 UTC Comment hidden (obsolete)
Comment 16 Björgvin Ragnarsson 2016-09-03 20:26:20 UTC
this is now also broken on linux after

commit 3cf557c12d27f1b2250e69a543136da098112d80
Author: Bjoern Michaelsen <bjoern.michaelsen@canonical.com>
Date:   Fri Oct 16 12:15:55 2015 +0100

    drop gconf integration as per ESC decision
Comment 17 Yousuf Philips (jay) (retired) 2017-09-18 12:10:25 UTC
This also should be done for Mac OS.