Re: [SailfishDevel] Folder permissions

2014-03-14 Thread Iosif Hamlatzis
I cannot use the %ghost directive as I don't know the names of the data
files that will be created during runtime, can I use the %ghost directive
with wildcards?. Also the folder I store my data files according to this
link https://harbour.jolla.com/faq#2.14.0 is $XDG_DATA_HOME/MyGameName
when I added in my .spec file packaging failed and according to the above
link it states

You must not hardcode */home/nemo/* or *$HOME/.config/*, etc. - use the Qt
5 QStandardPaths, GLib convenience methods or the xdg-helper library to
determine the paths. This will make sure your application keeps working for
sandboxed use cases, multi-user use cases as well as multi-profile
single-user use cases.


So which is the proper way to have the folders
*$XDG_CONFIG_HOME/HARBOUR_APP_NAME*   and
*$XDG_DATA_HOME/HARBOUR_APP_NAME*and
*$XDG_CACHE_HOME/HARBOUR_APP_NAME*  removed automatically when
removing my game?

These three folders aren't automatically created on installation and as I
understand I have to create them at run-time on my first run if I want to
use them.
___
SailfishOS.org Devel mailing list

Re: [SailfishDevel] Folder permissions

2014-03-14 Thread Iosif Hamlatzis
Thank you, a big burden has been lifted.

I can now start debugging the game on the actual device since the emulator
doesn't support landscape mode.


On 14 March 2014 12:53, Thomas Perl th.p...@gmail.com wrote:

 On 14 Mar 2014, at 11:37, Ove Kåven o...@arcticnet.no wrote:
  Den 13. mars 2014 19:22, skrev Iosif Hamlatzis:
  Thank you very much, I've just tested my game using the XDG basedir and
  it worked so I can continue my port of the game by modifying the rest of
  the code.
 
  Just one question, will the folders under .config/.cache/.local be
  removed if I uninstall the game? I've noticed that using the XDG basedir
  to read the environment variables I get something like:
  //MyGameName but no folder is created, so I programmatically
  created the MyGameName folder and placed my config (read/write) files.
 
  Since the GUI from the emulator doesn't uninstall the actual game I ssh
  into the emulator and called zypper remove MyGameName and it was
  uninstalled but the folders with all their contents I had created
  weren't erased. If this happens in the actual device then at some point
  there isn't going to be any space available on the device.
 
  I think you shouldn't worry about it, just leave the files in $HOME
 alone. I believe one of the reasons Jolla Harbour is trying to enforce that
 Harbour apps only write app-specific stuff into $HOME/.config/appname
 (instead of anywhere it likes under $HOME) is so that it will be easy for
 the Jolla Store to remove that directory when uninstalling. I don't think
 it does it yet, but it appears to be what they want it to do eventually. In
 any case, the rpm itself shouldn't worry about it.

 Exactly right :) Your RPM doesn't need to worry about it (in fact, can't -
 there's no way at package build time to determine what XDG will resolve to
 at runtime), and following the directory rules means the system can show
 per-app disk usage, allow users to clear the cache directory (even while
 the app is still installed, that's why it's called cache - no data in
 cache should be something that can't be deleted between invocations without
 losing user data), allow users to reset the app configuration (again, while
 the app is still installed - resetting the configuration without affecting
 the user data; that's why you should only put configuration settings in the
 config dir, and put user data into the data dir) can have per-app backup
 and restore and can clear app data on app uninstall, have per-TOH
 profiles for certain apps (example: TODO list with work TOH shows
 different contents than TODO list with party TOH), etc...

 And as Ove pointed out, this is not done yet, but will be done at some
 point in the future (having apps put their data into the right subfolder
 [named like the app name] of XDG basedir is a prerequisite for that) - in
 any case, something that app developers shouldn't need to worry about
 implementing themselves, just follow the XDG basedir spec with the addition
 of using the app name as subdirectory (as described in the Harbour FAQ) and
 expect that the system will handle clearing and backing up of cache, config
 and data (eventually).


 HTH :)
 Thomas
 ___
 SailfishOS.org Devel mailing list

___
SailfishOS.org Devel mailing list

Re: [SailfishDevel] Folder permissions

2014-03-13 Thread Jonni Rainisto
Did you remember to add %ghost in .spec files for rpm to claim ownership for 
files that you created? Afaik with that remove will also remove the files when 
package is uninstalled.


From: devel-boun...@lists.sailfishos.org [devel-boun...@lists.sailfishos.org] 
on behalf of Iosif Hamlatzis [i.hamlat...@gmail.com]
Sent: Thursday, March 13, 2014 8:22 PM
To: Sailfish OS Developers
Subject: Re: [SailfishDevel] Folder permissions

Thank you very much, I've just tested my game using the XDG basedir and it 
worked so I can continue my port of the game by modifying the rest of the code.

Just one question, will the folders under .config/.cache/.local be removed if I 
uninstall the game? I've noticed that using the XDG basedir to read the 
environment variables I get something like: //MyGameName but no 
folder is created, so I programmatically created the MyGameName folder and 
placed my config (read/write) files.

Since the GUI from the emulator doesn't uninstall the actual game I ssh into 
the emulator and called zypper remove MyGameName and it was uninstalled but 
the folders with all their contents I had created weren't erased. If this 
happens in the actual device then at some point there isn't going to be any 
space available on the device.
___
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

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 coderusin...@gmail.com 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 Thomas Perl
On 09 Mar 2014, at 18:56, Iosif Hamlatzis i.hamlat...@gmail.com 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/HARBOUR_APP_NAME/ 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 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 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 coderusin...@gmail.com 
mailto:coderusin...@gmail.com 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