Beispiel #1
0
static void wp_start_init(void)
{
	gchar *path = gmpc_plugin_get_data_path(&plugin);
	gchar *url = g_build_path(G_DIR_SEPARATOR_S,path, "wikipedia", NULL);
	gtk_icon_theme_append_search_path(gtk_icon_theme_get_default (),url);
	g_free(path);
	g_free(url);

	bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
	bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
}
Beispiel #2
0
/* return value should be free */
static gchar *
utt_get_user_article_dir ()
{
  gchar *dir;

  dir = g_build_path ("/", g_get_user_data_dir (), "utt", "wubi", "article", NULL);
  if (!g_file_test (dir, G_FILE_TEST_EXISTS)) {
    g_mkdir_with_parents (dir, S_IRWXU);
  }
  return dir;
}
Beispiel #3
0
/*
 * gvm_check_dvd_only - is this a Video DVD?
 *
 * Returns TRUE if this was a Video DVD and FALSE otherwise.
 * (the original in gvm was also running the autoplay action,
 * I removed that code, so I renamed from gvm_check_dvd to
 * gvm_check_dvd_only)
 */
static gboolean
gvm_check_dvd_only (const char *udi, const char *device, const char *mount_point)
{
	char *path;
	gboolean retval;
	
	path = g_build_path (G_DIR_SEPARATOR_S, mount_point, "video_ts", NULL);
	retval = g_file_test (path, G_FILE_TEST_IS_DIR);
	g_free (path);
	
	/* try the other name, if needed */
	if (retval == FALSE) {
		path = g_build_path (G_DIR_SEPARATOR_S, mount_point,
				     "VIDEO_TS", NULL);
		retval = g_file_test (path, G_FILE_TEST_IS_DIR);
		g_free (path);
	}
	
	return retval;
}
Beispiel #4
0
static gboolean
traverse_func (const char *path,
               const char *filename,
               gpointer data)
{
    ol_test_expect (GPOINTER_TO_INT (data) == 123);
    gchar *fullpath = g_build_path (G_DIR_SEPARATOR_S, path, filename, NULL);
    ol_test_expect (g_file_test (fullpath, G_FILE_TEST_EXISTS));
    g_free (fullpath);
    return TRUE;
}
Beispiel #5
0
/*!
 * Get the path of the specified file below the bundle path.
 *
 * \param bundle_path Full path to containers bundle path.
 * \param file Full path to file to find below \p bundle_path.
 *
 * \return Newly-allocated path string on success, else \c NULL.
 */
gchar *
cc_oci_get_bundlepath_file (const gchar *bundle_path,
		const gchar *file)
{
	if ((!bundle_path) || (!(*bundle_path)) ||
		(!file) || (!(*file))) {
		return NULL;
	}

	return g_build_path ("/", bundle_path, file, NULL);
}
Beispiel #6
0
static int init_sqlite_database (CcnetSession *session)
{
    char *db_path;

    db_path = g_build_path ("/", session->config_dir, CCNET_DB, NULL);
    session->db = ccnet_db_new_sqlite (db_path);
    if (!session->db) {
        g_warning ("Failed to open database.\n");
        return -1;
    }
    return 0;
}
Beispiel #7
0
int insecure_readlink (const char *path, char *link, size_t size) {
    insecure_flush_tables ();

    gchar *backname = insecure_get_backname (path);
    gchar *full_backname = g_build_path ("/", FS_DATA->backend_point, backname, NULL);

    ssize_t ret = readlink (full_backname, link, size - 1);
    if (ret < 0) return -errno;

    link[ret] = 0;
    return 0;
}
Beispiel #8
0
/* return value should be free */
static gchar *
utt_get_system_article_dir ()
{
  gchar *dir;

  dir = g_build_path ("/", PKGDATADIR, "article", NULL);
  if (!g_file_test (dir, G_FILE_TEST_EXISTS)) {
    g_free (dir);
    return NULL;
  }
  return dir;
}
Beispiel #9
0
static void
set_paths (void)
{
	/* Set PATH to include the Evolution executable's folder
	 * and the lib/evolution/$(BASE_VERSION)/components folder.
	 */
	wchar_t exe_filename[MAX_PATH];
	wchar_t *p;
	gchar *exe_folder_utf8;
	gchar *components_folder_utf8;
	gchar *top_folder_utf8;
	gchar *path;

	GetModuleFileNameW (NULL, exe_filename, G_N_ELEMENTS (exe_filename));

	p = wcsrchr (exe_filename, L'\\');
	g_assert (p != NULL);

	*p = L'\0';
	exe_folder_utf8 = g_utf16_to_utf8 (exe_filename, -1, NULL, NULL, NULL);

	p = wcsrchr (exe_filename, L'\\');
	g_assert (p != NULL);

	*p = L'\0';
	top_folder_utf8 = g_utf16_to_utf8 (exe_filename, -1, NULL, NULL, NULL);
	components_folder_utf8 =
		g_strconcat (top_folder_utf8,
			     "/lib/evolution/" BASE_VERSION "/components",
			     NULL);

	path = g_build_path (";",
			     exe_folder_utf8,
			     components_folder_utf8,
			     g_getenv ("PATH"),
			     NULL);
	if (!g_setenv ("PATH", path, TRUE))
		g_warning ("Could not set PATH for Evolution and its child processes");

	g_free (path);

	/* Set BONOBO_ACTIVATION_PATH */
	if (g_getenv ("BONOBO_ACTIVATION_PATH" ) == NULL) {
		path = g_build_filename (top_folder_utf8,
					 "lib/bonobo/servers",
					 NULL);
		if (!g_setenv ("BONOBO_ACTIVATION_PATH", path, TRUE))
			g_warning ("Could not set BONOBO_ACTIVATION_PATH");
		g_free (path);
	}
	g_free (top_folder_utf8);
}
Beispiel #10
0
static void
initialize_main_loop (void)
{
    GtpEngineList site_configuration_engines;

#if THREADS_SUPPORTED
    thread_events_queue = g_async_queue_new ();

    thread_events = g_source_new (&thread_events_functions, sizeof (GSource));
    g_source_set_callback (thread_events, thread_event_callback, NULL, NULL);
    g_source_attach (thread_events, NULL);
#endif

    quarry_stock_init ();

    user_real_name = g_get_real_name ();
    configuration_init (gtk_configuration_sections,
                        NUM_GTK_CONFIGURATION_SECTIONS);

    /* Try to read site configuration file.  Later,
     * configuration_write_to_file() will effectively copy all
     * site-default settings to user's configuration, with any changes
     * she has made.
     *
     * Site configuration file is meant for distributions, to
     * e.g. automatically register GNU Go with Quarry.
     */
    configuration_read_from_file (gtk_configuration_sections,
                                  NUM_GTK_CONFIGURATION_SECTIONS,
                                  PACKAGE_DATA_DIR "/quarry.cfg");

    gtp_engine_list_init (&site_configuration_engines);
    string_list_steal_items (&site_configuration_engines, &gtp_engines);

    configuration_file = g_build_path (G_DIR_SEPARATOR_S,
                                       g_get_home_dir (), ".quarry", NULL);
    configuration_read_from_file (gtk_configuration_sections,
                                  NUM_GTK_CONFIGURATION_SECTIONS,
                                  configuration_file);

    configuration_combine_string_lists (&gtp_engines,
                                        &site_configuration_engines,
                                        (G_STRUCT_OFFSET
                                         (GtpEngineListItem,
                                          site_configuration_name)));

    gtk_preferences_init ();

#if GTK_2_2_OR_LATER
    gtk_window_set_default_icon_from_file (DATA_DIR "/pixmaps/quarry.png", NULL);
#endif
}
Beispiel #11
0
/**
 * @return The quetoo-installer jar file.
 */
static gchar *get_quetoo_installer_jar(const char *argv0, const char *jar) {

	gchar *update_jar = NULL;

	char *path = realpath(argv0, NULL);
	if (path) {

		gchar *dir = g_path_get_dirname(path);
		if (dir) {
#if defined(__APPLE__)
			update_jar = g_build_path(G_DIR_SEPARATOR_S, dir, "lib", jar, NULL);
#else
			update_jar = g_build_path(G_DIR_SEPARATOR_S, dir, "..", "lib", jar, NULL);
#endif
			g_free(dir);
		}

		free(path);
	}

	return update_jar;
}
Beispiel #12
0
int insecure_truncate (const char *path, off_t newsize) {
    printf ("truncate\n");
    insecure_flush_tables ();
    struct insecure_state *state = FS_DATA;

    gchar *backname = insecure_get_backname (path);
    gchar *full_backname = g_build_path ("/", state->backend_point, backname, NULL);

    int ret = truncate (full_backname, newsize);
    g_free (full_backname);
    g_free (backname);
    return ret;
}
Beispiel #13
0
void
rss_soup_init(void)
{
	g_print("soup init()\n");
	settings = g_settings_new(RSS_CONF_SCHEMA);

#if LIBSOUP_VERSION > 2026002 && defined(HAVE_LIBSOUP_GNOME)
#if EVOLUTION_VERSION < 30304
	if (gconf_client_get_bool (rss_gconf, GCONF_KEY_ACCEPT_COOKIES, NULL)) {
#else
	if (g_settings_get_boolean (settings, CONF_ACCEPT_COOKIES)) {
#endif
		gchar *feed_dir = rss_component_peek_base_directory();
		gchar *cookie_path = g_build_path(
					G_DIR_SEPARATOR_S,
					feed_dir,
					"rss-cookies.sqlite",
					NULL);
		gchar *moz_cookie_path = g_build_path(
						G_DIR_SEPARATOR_S,
						feed_dir,
						"mozembed-rss",
						"cookies.sqlite",
						NULL);
		g_free(feed_dir);

		rss_soup_jar =
			soup_cookie_jar_db_new (cookie_path, FALSE);

		if (!g_file_test(moz_cookie_path, G_FILE_TEST_EXISTS|G_FILE_TEST_IS_SYMLINK)) {
			sync_gecko_cookies();
		}
		g_free(cookie_path);
		g_free(moz_cookie_path);
	}
#endif
	if (!rf->stqueue)
		rf->stqueue = g_queue_new();
}
Beispiel #14
0
/* Looks up a freedesktop.org compliant cover for the given path. */
char *
lookup_cover(const char *path) {

  GKeyFile *keyfile;
  char *keyfilepath;
  char *value;
  char *coverpath;

  /* build path to the .directory desktop file */
  keyfilepath = g_build_path("/", path, ".directory", NULL);

  if (g_file_test(keyfilepath, G_FILE_TEST_EXISTS)) {
  
    /* read desktop file */
    keyfile = g_key_file_new();
    g_key_file_load_from_file(keyfile, keyfilepath, G_KEY_FILE_NONE, NULL);

    /* read icon entry */
    value = g_key_file_get_string(keyfile, "Desktop Entry", "Icon", NULL);

    if (g_path_is_absolute(value))
      coverpath = g_strdup(value);
    else
      coverpath = g_build_path("/", path, value, NULL);

    g_free(value);
    g_key_file_free(keyfile);

  } else {

    coverpath = NULL;

  }

  g_free(keyfilepath);  

  return coverpath;
  
}
Beispiel #15
0
gchar *
configuration_get_filename (void)
{
	gchar *filename, *dir;

	dir = g_new0 (gchar, XMMS_PATH_MAX);
	xmmsc_userconfdir_get (dir, XMMS_PATH_MAX);
	filename = g_build_path (G_DIR_SEPARATOR_S, dir, "clients",
	                         "nycli.conf", NULL);
	g_free (dir);

	return filename;
}
Beispiel #16
0
/* Gets the directory path of a filename.
   Uses current working directory if filename is a relative pathname.
   Examples:
     /some/dir/file.gif => /some/dir
     dir/file.gif => /cwd/dir
   
*/
static char *
get_directory(const char *filename) 
{
  char *cwd;
  char *directory;
  char *dirname;
  
  if (filename==NULL)
    return NULL;

  dirname = g_path_get_dirname(filename);
  if (g_path_is_absolute(dirname)) {
      directory = g_build_path(G_DIR_SEPARATOR_S, dirname, NULL);
  } else {
      cwd = g_get_current_dir();
      directory = g_build_path(G_DIR_SEPARATOR_S, cwd, dirname, NULL);
      g_free(cwd);
  }
  g_free(dirname);

  return directory;
}
Beispiel #17
0
static GFile *
gimp_export_dialog_get_default_folder (Gimp *gimp)
{
  if (gimp->default_folder)
    {
      return gimp->default_folder;
    }
  else
    {
      GFile *file = g_object_get_data (G_OBJECT (gimp),
                                       "gimp-documents-folder");

      if (! file)
        {
          gchar *path;

          /* Make sure it ends in '/' */
          path = g_build_path (G_DIR_SEPARATOR_S,
                               g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS),
                               G_DIR_SEPARATOR_S,
                               NULL);

          /* Paranoia fallback, see bug #722400 */
          if (! path)
            path = g_build_path (G_DIR_SEPARATOR_S,
                                 g_get_home_dir (),
                                 G_DIR_SEPARATOR_S,
                                 NULL);

          file = g_file_new_for_path (path);
          g_free (path);

          g_object_set_data_full (G_OBJECT (gimp), "gimp-documents-folder",
                                  file, (GDestroyNotify) g_object_unref);
        }

      return file;
    }
}
Beispiel #18
0
/********************************
* Patch_ScanCurrent
*
@ store:
@ game_files:
*/
void Patch_ScanCurrent( GtkListStore * store, GSList * game_files )
{
	GtkTreeIter children;
	gchar * directory_path, * file_path, * package_file;
	const gchar * current;
	GDir * directory;
	guint array_count = 0;

	gtk_list_store_clear( store );

	if ( g_strv_length( mokoiPatchDirectories ) )
	{
		while ( mokoiPatchDirectories[array_count] != NULL )
		{
			directory_path = g_build_path( G_DIR_SEPARATOR_S, mokoiBasePath, mokoiPatchDirectories[array_count], NULL );
			directory = g_dir_open( directory_path, 0, NULL);
			current = g_dir_read_name( directory );
			while ( current != NULL )
			{
				if ( current[0] != '.' )
				{
					package_file = g_build_path( "/", mokoiPatchDirectories[array_count], current, NULL );
					file_path = g_build_filename( directory_path, current, NULL );
					if ( g_file_test( file_path, G_FILE_TEST_IS_REGULAR ) )
					{
						gtk_list_store_append( store, &children );
						gtk_list_store_set( store, &children, 0, Patch_HasChanged( game_files, package_file, file_get_size(file_path) ), 1, package_file, -1 );
					}
					g_free( package_file );
					g_free( file_path );
				}
				current = g_dir_read_name( directory );
			}
			g_dir_close( directory );
			array_count++;
		}
	}

}
Beispiel #19
0
/* Creates program related directories if needed */
void check_dirs()
{
	gchar *data_dir = g_build_path(G_DIR_SEPARATOR_S, g_get_user_data_dir(), DATA_DIR, NULL);
	gchar *config_dir = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), CONFIG_DIR, NULL);
	/* Check if data directory exists */
	if (!g_file_test(data_dir, G_FILE_TEST_EXISTS))
	{
		/* Try to make data directory */
		if (g_mkdir_with_parents(data_dir, 0755) != 0)
			g_warning(_("Couldn't create directory: %s\n"), data_dir);
	}
	/* Check if config directory exists */
	if (!g_file_test(config_dir, G_FILE_TEST_EXISTS))
	{
		/* Try to make config directory */
		if (g_mkdir_with_parents(config_dir, 0755) != 0)
			g_warning(_("Couldn't create directory: %s\n"), config_dir);
	}
	/* Cleanup */
	g_free(data_dir);
	g_free(config_dir);
}
static void
delete_db (gboolean del_journal)
{
    gchar *meta_db, *db_location;

    db_location = g_build_path (G_DIR_SEPARATOR_S, g_get_current_dir (), "tracker", NULL);
    meta_db = g_build_path (G_DIR_SEPARATOR_S, db_location, "meta.db", NULL);
    g_unlink (meta_db);
    g_free (meta_db);

    if (del_journal) {
        meta_db = g_build_path (G_DIR_SEPARATOR_S, db_location, "data", "tracker-store.journal", NULL);
        g_unlink (meta_db);
        g_free (meta_db);
    }

    meta_db = g_build_path (G_DIR_SEPARATOR_S, db_location, "data", ".meta.isrunning", NULL);
    g_unlink (meta_db);
    g_free (meta_db);

    g_free (db_location);
}
Beispiel #21
0
static void
test_query (TestInfo      *test_info,
            gconstpointer  context)
{
	GError *error = NULL;
	gchar *data_filename;
	gchar *query_filename;
	gchar *results_filename;
	gchar *prefix, *data_prefix, *test_prefix;

	prefix = g_build_path (G_DIR_SEPARATOR_S, TOP_SRCDIR, "tests", "libtracker-data", NULL);
	data_prefix = g_build_filename (prefix, test_info->data, NULL);
	test_prefix = g_build_filename (prefix, test_info->test_name, NULL);
	g_free (prefix);

	tracker_db_journal_set_rotating (FALSE, G_MAXSIZE, NULL);

	/* initialization */
	tracker_data_manager_init (TRACKER_DB_MANAGER_FORCE_REINDEX,
	                           NULL,
	                           NULL,
	                           FALSE,
	                           FALSE,
	                           100,
	                           100,
	                           NULL,
	                           NULL,
	                           NULL,
	                           NULL);

	/* load data set */
	data_filename = g_strconcat (data_prefix, ".ttl", NULL);
	tracker_turtle_reader_load (data_filename, &error);
	g_assert_no_error (error);

	query_filename = g_strconcat (test_prefix, ".rq", NULL);
	results_filename = g_strconcat (test_prefix, ".out", NULL);

	g_free (data_prefix);
	g_free (test_prefix);

	query_helper (query_filename, results_filename);

	/* cleanup */

	g_free (data_filename);
	g_free (query_filename);
	g_free (results_filename);

	tracker_data_manager_shutdown ();
}
static gboolean
slmock_check_login(GDBusConnection * session, slmock_table_t * slmockdata, gboolean clear_cache)
{
	if (clear_cache) {
		gchar *username_sha = g_compute_checksum_for_string (G_CHECKSUM_SHA256, slmockdata->username, -1);
		gchar *file_path = g_build_path ("/", g_get_user_cache_dir(), "remote-logon-service", "cache", username_sha, NULL);
		unlink (file_path);
		g_free (username_sha);
		g_free (file_path);
	}
	GVariant * retval = g_dbus_connection_call_sync(session,
	                                                "org.ArcticaProject.RemoteLogon",
	                                                "/org/ArcticaProject/RemoteLogon",
	                                                "org.ArcticaProject.RemoteLogon",
	                                                "GetServersForLogin",
	                                                g_variant_new("(sssb)",
	                                                              "https://slmock.com/",
	                                                              slmockdata->username,
	                                                              slmockdata->password,
	                                                              TRUE), /* params */
	                                                G_VARIANT_TYPE("(bsa(sssba(sbva{sv})a(si)))"), /* ret type */
	                                                G_DBUS_CALL_FLAGS_NONE,
	                                                -1,
	                                                NULL,
	                                                NULL);

	g_assert(retval != NULL);
	g_assert(g_variant_n_children(retval) == 3);

	GVariant * loggedin = g_variant_get_child_value(retval, 0);
	g_assert(g_variant_get_boolean(loggedin));
	g_variant_unref(loggedin); loggedin = NULL;

	GVariant * data = g_variant_get_child_value(retval, 1);
	g_assert(g_strcmp0(g_variant_get_string(data, NULL), "network") == 0);
	g_variant_unref(data); data = NULL;

	GVariant * array = g_variant_get_child_value(retval, 2);
	int i;
	// Check all servers should be in the result are in the result
	for (i = 0; slmockdata->servers[i].name != NULL; i++) {
		g_assert(find_server(array, &slmockdata->servers[i]));
	}
	// Check there is no more servers in the result than we expected
	g_assert(i == g_variant_n_children(array));
	g_variant_unref(array);

	g_variant_unref(retval);

	return TRUE;
}
Beispiel #23
0
gboolean
mux_maildir_make (const char* path, mode_t mode, GError **err)
{
    gboolean	rv;
    guint		u;
    const gchar* subdirs[] = {"new", "cur", "tmp"};

    g_return_val_if_fail (path, FALSE);

    for (u = 0, rv = TRUE; rv && u != G_N_ELEMENTS(subdirs); ++u) {

        char	*fullpath;

        rv	 = FALSE;
        fullpath = g_build_path (G_DIR_SEPARATOR_S,
                                 path, subdirs[u], NULL);

        /* existing dir is okay */
        if (access (fullpath, F_OK|R_OK|W_OK) == 0) {
            struct stat statbuf;
            if (stat (fullpath, &statbuf) != 0) {
                g_set_error (err, G_IO_ERROR,
                             g_io_error_from_errno(errno),
                             "can't stat %s: %s", fullpath,
                             strerror (errno));
                goto done;
            }

            if (!S_ISDIR(statbuf.st_mode)) {
                g_set_error (err, G_IO_ERROR, G_IO_ERROR_EXISTS,
                             "%s already exists", fullpath);
                goto done;
            }
        }

        if (g_mkdir_with_parents (fullpath, (int)mode) != 0) {
            g_set_error (err, G_IO_ERROR,
                         g_io_error_from_errno(errno),
                         "can't create %s: %s", fullpath,
                         strerror (errno));
            goto done;
        }

        rv = TRUE;

done:
        g_free (fullpath);
    }

    return rv;
}
Beispiel #24
0
int32_t dt_camera_import_backup_job_run(dt_job_t *job)
{
  // copy sourcefile to each found destination
  dt_camera_import_backup_t *t = (dt_camera_import_backup_t *)job->param;
  GVolumeMonitor *vmgr= g_volume_monitor_get();
  GList *mounts=g_volume_monitor_get_mounts(vmgr);
  GMount *mount=NULL;
  GFile *root=NULL;
  if( mounts !=NULL )
    do
    {
      mount=G_MOUNT(mounts->data);
      if( ( root=g_mount_get_root( mount ) ) != NULL )
      {
        // Got the mount point lets check for backup folder
        gchar *backuppath=NULL;
        gchar *rootpath=g_file_get_path(root);
        backuppath=g_build_path(G_DIR_SEPARATOR_S,rootpath,dt_conf_get_string("plugins/capture/backup/foldername"),(char *)NULL);
        g_free(rootpath);

        if( g_file_test(backuppath,G_FILE_TEST_EXISTS)==TRUE)
        {
          // Found a backup storage, lets copy file here..
          gchar *destinationfile=g_build_filename(G_DIR_SEPARATOR_S,backuppath,t->destinationfile,(char *)NULL);
          if( g_mkdir_with_parents(g_path_get_dirname(destinationfile),0755) >= 0 )
          {
            gchar *content;
            gsize size;
            if( g_file_get_contents(t->sourcefile,&content,&size,NULL) == TRUE )
            {
              GError *err=NULL;
              if( g_file_set_contents(destinationfile,content,size,&err) != TRUE)
              {
                fprintf(stderr,"Failed to set content of file with reason: %s\n",err->message);
                g_error_free(err);
              }
              g_free(content);
            }
          }
          g_free(destinationfile);
        }

        g_free(backuppath);
      }
    }
    while( (mounts=g_list_next(mounts)) !=NULL);

  // Release volume manager
  g_object_unref(vmgr);
  return 0;
}
Beispiel #25
0
/** Create and save a configuration file containing the given data.
 *
 * @note: All fields must specified and be non-null
 *
 * @param root_key The root key
 * @param root_cert The root certificate
 * @param host_key The host key
 * @param host_cert The host certificate
 *
 * @return 1 on success and 0 otherwise.
 */
userpref_error_t userpref_set_keys_and_certs(gnutls_datum_t * root_key, gnutls_datum_t * root_cert, gnutls_datum_t * host_key, gnutls_datum_t * host_cert)
{
	FILE *pFile;
	gchar *pem;

	if (!root_key || !host_key || !root_cert || !host_cert)
		return USERPREF_E_INVALID_ARG;

	/* Make sure config directory exists */
	userpref_create_config_dir();

	/* Now write keys and certificates to disk */
	pem = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, LIBIPHONE_ROOT_PRIVKEY, NULL);
	pFile = fopen(pem, "wb");
	fwrite(root_key->data, 1, root_key->size, pFile);
	fclose(pFile);
	g_free(pem);

	pem = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, LIBIPHONE_HOST_PRIVKEY, NULL);
	pFile = fopen(pem, "wb");
	fwrite(host_key->data, 1, host_key->size, pFile);
	fclose(pFile);
	g_free(pem);

	pem = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, LIBIPHONE_ROOT_CERTIF, NULL);
	pFile = fopen(pem, "wb");
	fwrite(root_cert->data, 1, root_cert->size, pFile);
	fclose(pFile);
	g_free(pem);

	pem = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, LIBIPHONE_HOST_CERTIF, NULL);
	pFile = fopen(pem, "wb");
	fwrite(host_cert->data, 1, host_cert->size, pFile);
	fclose(pFile);
	g_free(pem);

	return USERPREF_E_SUCCESS;
}
static gchar *
get_path (void)
{
  gchar *free_dir = NULL, *ret;
  const gchar *dir, *path;

  /* This should still work if it's the magic value ":memory:". */
  path = g_getenv ("WOCKY_CAPS_CACHE");

  if (path != NULL)
    {
      dir = free_dir = g_path_get_dirname (path);
      ret = g_strdup (path);
    }
  else
    {
      dir = g_getenv ("WOCKY_CACHE_DIR");

      if (dir != NULL)
        {
          ret = g_build_path (G_DIR_SEPARATOR_S, dir, "caps-cache.db", NULL);
        }
      else
        {
          ret = g_build_path (G_DIR_SEPARATOR_S,
              g_get_user_cache_dir (), "wocky", "caps", "caps-cache.db",
              NULL);
          dir = free_dir = g_path_get_dirname (ret);
        }
    }

  /* Any errors are ignored here, on the basis that we'll find out the path is
   * duff when we try to open the database anyway.
   */
  g_mkdir_with_parents (dir, 0755);
  g_free (free_dir);
  return ret;
}
static gboolean
_prepend_cmd_to_list (const char *path,
                      const char *filename,
                      gpointer userdata)
{
  GList **cmds_p = userdata;
  gchar *filepath = g_build_path (G_DIR_SEPARATOR_S, path, filename, NULL);
  if (g_file_test (filepath, G_FILE_TEST_IS_EXECUTABLE) &&
      !g_file_test (filepath, G_FILE_TEST_IS_DIR))
  {
    *cmds_p = g_list_prepend (*cmds_p, g_strdup (filename));
  }
  return TRUE;
}
Beispiel #28
0
/** Determines whether this iPhone has been connected to this system before.
 *
 * @param uid The device uid as given by the iPhone.
 *
 * @return 1 if the iPhone has been connected previously to this configuration
 *         or 0 otherwise.
 */
int userpref_has_device_public_key(const char *uuid)
{
	int ret = 0;
	gchar *config_file;

	/* first get config file */
	gchar *device_file = g_strconcat(uuid, ".pem", NULL);
	config_file = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, device_file, NULL);
	if (g_file_test(config_file, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)))
		ret = 1;
	g_free(config_file);
	g_free(device_file);
	return ret;
}
static void
empathy_log_store_empathy_init (EmpathyLogStoreEmpathy *self)
{
  EmpathyLogStoreEmpathyPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
      EMPATHY_TYPE_LOG_STORE_EMPATHY, EmpathyLogStoreEmpathyPriv);

  self->priv = priv;

  priv->basedir = g_build_path (G_DIR_SEPARATOR_S, g_get_user_data_dir (),
    PACKAGE_NAME, "logs", NULL);

  priv->name = g_strdup ("Empathy");
  priv->account_manager = tp_account_manager_dup ();
}
Beispiel #30
0
static gchar *
utt_generate_new_article_path ()
{
  uuid_t uuid;
  gchar uuid_str[37];
  gchar *path, *dir;

  uuid_generate (uuid);
  uuid_unparse (uuid, uuid_str);
  dir = utt_get_user_article_dir ();
  path = g_build_path ("/", dir, uuid_str, NULL);
  g_free (dir);
  return path;
}