Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/sugar.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sugar.c')
-rw-r--r--src/sugar.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/sugar.c b/src/sugar.c
index 7e5b727..198f69f 100644
--- a/src/sugar.c
+++ b/src/sugar.c
@@ -21,7 +21,9 @@
(See COPYING.txt)
*/
+#include <unistd.h>
#include <SDL/SDL_syswm.h>
+
#include <sugar/env.h>
#include <sugar/ds.h>
#include <sugar/shell.h>
@@ -47,8 +49,13 @@ void sugar_init(int * argc, char *** argv)
if (sugar_handle_get_object_id(handle) != NULL)
jobject = sugar_jobject_find(sugar_handle_get_object_id(handle));
- if (jobject == NULL)
+ if (jobject != NULL)
+ g_debug("Journal entry %s was found", sugar_handle_get_object_id(handle));
+ else
+ {
jobject = sugar_jobject_create(sugar_handle_get_activity_id(handle));
+ g_debug("Create new Journal entry");
+ }
}
void sugar_cleanup()
@@ -74,7 +81,7 @@ void sugar_cleanup()
void sugar_setup_x11(int * window_width, int * window_height)
{
if (!sugar_detected())
- return NULL;
+ return;
SDL_SysWMinfo wminfo;
SDL_VERSION(&wminfo.version);
@@ -108,7 +115,7 @@ char * sugar_get_jobject_file()
if (!sugar_detected())
return NULL;
- char * file_path = sugar_jobject_get_file_path(jobject);
+ const char * file_path = sugar_jobject_get_file_path(jobject);
if (file_path != NULL)
g_debug("Load image from journal entry %s", sugar_jobject_get_uid(jobject));
@@ -124,7 +131,14 @@ void sugar_save_jobject_file(char * path)
if (sugar_jobject_get_uid(jobject) == NULL)
new_jobject |= TRUE;
- sugar_jobject_write_file(jobject, path, TRUE);
+ if (!sugar_environ_get_secure_mode())
+ sugar_jobject_write_file(jobject, path, TRUE);
+ else {
+ /* There is no way to just move files to the datastore w/o creating 0777
+ * directories, thus have to copy files */
+ sugar_jobject_write_file(jobject, path, FALSE);
+ unlink(path);
+ }
g_debug("Saved %s image to journal entry %s", path,
sugar_jobject_get_uid(jobject));
@@ -132,5 +146,5 @@ void sugar_save_jobject_file(char * path)
char * sugar_get_savedir(void)
{
- return g_strdup_printf("%s/data", sugar_profile_get_activity_root());
+ return g_strdup_printf("%s/data", sugar_environ_get_activity_root());
}