Re: [SailfishDevel] Folder permissions

2014-03-09 Thread Andrey Kozhevnikov

QDir::homePath() inside app

while deploying you shouldnt copy anything to home. /usr/share for const 
predefined data. $HOME/.local/share/appname for any downloaded/created 
internal (!) application data like caches. Downloaded media you can save 
in Video/Pictures/Music folders.

For settings use QSettings class and set default values in code like:

bool mySetting = settings.getValue("mySetting", true).toBool();

And remember: we can help you make your application better, we cant help 
you continue development in bad direction.


On 09.03.2014 23:56, Iosif Hamlatzis wrote:
ok and the next logical question is: How to get the $HOME folder of 
the emulator or later the actual device in my .pro file? I think it 
shouldn't be hard-coded.


I tried to use: "/$$(HOME)/.local/share/$${TARGET}" but it seams this 
translates into /home/*_mersdk_*/.local/share/FarWest/Home/ which is 
wrong and the deployment fails.


Is this another "feature" of the QtCreator IDE? And when I say 
"feature" I mean a bug, another thing that doesn't work like debugging 
on the emulator or the device from inside the IDE and I would have to 
resolve to command line again?





On 9 March 2014 19:35, Andrey Kozhevnikov > wrote:


/usr/share/appname is read only for applications

$HOME/.local/share/appname is read and write


On 09.03.2014 23:33, Iosif Hamlatzis wrote:

When deploying a game/application where should its resources
(images/sounds/settings files) be stored so that the
game/application can have both read and write permissions?

I tried to use the /usr/share/$$(TARGET) folder where $$(TARGET)
is the name of my game but it seams the game doesn't have
permissions on this folder. Not even read permissions.

I use:

FILE* pFile = fopen("/usr/share/MyGame/Home/settings.bin", "r+b");
and pFile is NULL, I know the file exists because I ssh into the
emulator and my resources are all there under the folder, so the
deployment succeeded but I notice the owner and the group is root
although I would have expected something like nemo.


___
SailfishOS.org Devel mailing list



___
SailfishOS.org Devel mailing list




___
SailfishOS.org Devel mailing list


___
SailfishOS.org Devel mailing list

Re: [SailfishDevel] Folder permissions

2014-03-09 Thread Ove Kåven

Den 09. mars 2014 18:33, skrev Iosif Hamlatzis:

When deploying a game/application where should its resources
(images/sounds/settings files) be stored so that the game/application
can have both read and write permissions?


You should clarify why you need write permissions, so that it's possible 
to suggest the best way to handle your situation. In general, files 
distributed as part of the rpm should never be written to.


If it's only things like config files or high scores that you need to 
write, then there's standard ways to do it. They should be placed into 
the user's home directory on first startup of your game, either by being 
created from scratch, or by copying an initial version from your 
/usr/share directory. (But don't hardcode /home. The best way to get the 
path is to use QStandardPaths::writableLocation.)



I tried to use the /usr/share/$$(TARGET) folder where $$(TARGET) is the
name of my game but it seams the game doesn't have permissions on this
folder. Not even read permissions.


No, you should have read permissions. You just can't write.


I use:

FILE* pFile = fopen("/usr/share/MyGame/Home/settings.bin", "r+b");


That's not read permissions, You're asking for *both* read and write 
permissions, which is denied because you can only have read permissions, 
not write. To request read permissions only, use just "rb", not "r+b".


___
SailfishOS.org Devel mailing list


Re: [SailfishDevel] Folder permissions

2014-03-09 Thread Thomas Perl
On 09 Mar 2014, at 18:56, Iosif Hamlatzis  wrote:
> ok and the next logical question is: How to get the $HOME folder of the 
> emulator or later the actual device in my .pro file? I think it shouldn't be 
> hard-coded.

The Harbour FAQ has several detailed answers about where to ship (sic) 
read-only data in an RPM and where to store data at run-time:

"Can I install files in /home/nemo?”
https://harbour.jolla.com/faq#2.4.0

"I have a huge amount of data files which the user can edit/change during run 
time. What can I do?”
https://harbour.jolla.com/faq#2.5.0

"Why can't I set a folder or a file under /usr/share// to be 
world writeable?”
https://harbour.jolla.com/faq#2.12.0

“Where should I store application configuration, application data and cache 
files?”
https://harbour.jolla.com/faq#2.13.0

“$XDG_CONFIG_HOME, $XDG_DATA_HOME and $XDG_CACHE_HOME are not set in the device 
environment. So which path should I use?”
https://harbour.jolla.com/faq#2.14.0


For implementing XDG basedir, there’s a library, plus two README files (one for 
when you use Qt and one for when you use GLib, as both already implement XDG 
basedir):

https://github.com/sailfish-sdk/xdg-helper


HTH :)
Thomas
___
SailfishOS.org Devel mailing list


Re: [SailfishDevel] Folder permissions

2014-03-09 Thread Iosif Hamlatzis
ok and the next logical question is: How to get the $HOME folder of the
emulator or later the actual device in my .pro file? I think it shouldn't
be hard-coded.

I tried to use: "/$$(HOME)/.local/share/$${TARGET}" but it seams this
translates into /home/*mersdk*/.local/share/FarWest/Home/ which is wrong
and the deployment fails.

Is this another "feature" of the QtCreator IDE? And when I say "feature" I
mean a bug, another thing that doesn't work like debugging on the emulator
or the device from inside the IDE and I would have to resolve to command
line again?




On 9 March 2014 19:35, Andrey Kozhevnikov  wrote:

>  /usr/share/appname is read only for applications
>
> $HOME/.local/share/appname is read and write
>
>
> On 09.03.2014 23:33, Iosif Hamlatzis wrote:
>
>  When deploying a game/application where should its resources
> (images/sounds/settings files) be stored so that the game/application can
> have both read and write permissions?
>
>  I tried to use the /usr/share/$$(TARGET) folder where $$(TARGET) is the
> name of my game but it seams the game doesn't have permissions on this
> folder. Not even read permissions.
>
>  I use:
>
>  FILE* pFile = fopen("/usr/share/MyGame/Home/settings.bin", "r+b");
> and pFile is NULL, I know the file exists because I ssh into the emulator
> and my resources are all there under the folder, so the deployment
> succeeded but I notice the owner and the group is root although I would
> have expected something like nemo.
>
>
> ___
> SailfishOS.org Devel mailing list
>
>
>
> ___
> SailfishOS.org Devel mailing list
>
___
SailfishOS.org Devel mailing list

Re: [SailfishDevel] Folder permissions

2014-03-09 Thread Andrey Kozhevnikov

/usr/share/appname is read only for applications

$HOME/.local/share/appname is read and write

On 09.03.2014 23:33, Iosif Hamlatzis wrote:
When deploying a game/application where should its resources 
(images/sounds/settings files) be stored so that the game/application 
can have both read and write permissions?


I tried to use the /usr/share/$$(TARGET) folder where $$(TARGET) is 
the name of my game but it seams the game doesn't have permissions on 
this folder. Not even read permissions.


I use:

FILE* pFile = fopen("/usr/share/MyGame/Home/settings.bin", "r+b");
and pFile is NULL, I know the file exists because I ssh into the 
emulator and my resources are all there under the folder, so the 
deployment succeeded but I notice the owner and the group is root 
although I would have expected something like nemo.



___
SailfishOS.org Devel mailing list


___
SailfishOS.org Devel mailing list

[SailfishDevel] Folder permissions

2014-03-09 Thread Iosif Hamlatzis
When deploying a game/application where should its resources
(images/sounds/settings files) be stored so that the game/application can
have both read and write permissions?

I tried to use the /usr/share/$$(TARGET) folder where $$(TARGET) is the
name of my game but it seams the game doesn't have permissions on this
folder. Not even read permissions.

I use:

FILE* pFile = fopen("/usr/share/MyGame/Home/settings.bin", "r+b");
and pFile is NULL, I know the file exists because I ssh into the emulator
and my resources are all there under the folder, so the deployment
succeeded but I notice the owner and the group is root although I would
have expected something like nemo.
___
SailfishOS.org Devel mailing list