Back to index

gcompris  8.2.2
Functions
profile.c File Reference
#include <stdio.h>
#include "gcompris.h"
#include "properties.h"

Go to the source code of this file.

Functions

GcomprisProfilegc_profile_get_current ()
 Return the current profile or NULL if sqlite not activated.
void gc_profile_set_current_user (GcomprisUser *user)
void gc_profile_destroy (GcomprisProfile *prof)
void gc_user_destroy (GcomprisUser *user)
GcomprisUser * gc_profile_get_current_user ()

Function Documentation

Definition at line 83 of file profile.c.

{
  if(!prof)
    return;

  g_free(prof->name);
  g_free(prof->directory);
  g_free(prof->description);
  g_free(prof);
}

Here is the caller graph for this function:

Return the current profile or NULL if sqlite not activated.

Definition at line 30 of file profile.c.

{
  GcomprisProperties *properties = gc_prop_get();

  if (properties->profile)
    return properties->profile;

  properties->profile = gc_db_get_profile();

  return properties->profile;

}

Here is the call graph for this function:

Here is the caller graph for this function:

GcomprisUser* gc_profile_get_current_user ( )

Definition at line 107 of file profile.c.

{
  GcomprisProperties *properties = gc_prop_get();
  return properties->logged_user;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gc_profile_set_current_user ( GcomprisUser *  user)

Definition at line 45 of file profile.c.

{
  GcomprisProperties *properties = gc_prop_get();

  if (user)
    properties->logged_user = user;
  else {
    g_warning("No user, getting one from system.");
    GcomprisUser *sys_user = g_malloc0(sizeof(GcomprisUser));

    const gchar *user_name = g_get_user_name ();
    if (user_name)
      sys_user->login = g_strdup(user_name);
    else
      sys_user->login = g_strdup("nobody");

    const gchar *last_name = g_get_real_name ();
    if (last_name)
      sys_user->lastname = g_strdup(last_name);
    else
      sys_user->lastname = g_strdup("Nobody There ?");

    sys_user->firstname = g_strdup("Unknown");
    sys_user->birthdate = g_strdup("");

    properties->logged_user = sys_user;
  }

  GTimeVal now;
  g_get_current_time (&now);

  gchar *session_id_str = g_strdup_printf("%s%ld%ld", (properties->logged_user)->login, now.tv_sec, now.tv_usec);

  (properties->logged_user)->session_id = g_str_hash((gconstpointer) session_id_str);
  g_free(session_id_str);

}

Here is the call graph for this function:

Here is the caller graph for this function:

void gc_user_destroy ( GcomprisUser *  user)

Definition at line 94 of file profile.c.

{
  if(!user)
    return;

  g_free(user->login);
  g_free(user->lastname);
  g_free(user->firstname);
  g_free(user->birthdate);
  g_free(user);
}

Here is the caller graph for this function: