xap/linphone: Patched for XDG Basedir support

This commit is contained in:
Damien Goutte-Gattat 2012-01-07 14:04:27 +01:00
parent fb5f65c636
commit 3d6792c1d5
2 changed files with 111 additions and 2 deletions

View File

@ -0,0 +1,107 @@
diff --git a/console/linphonec.c b/console/linphonec.c
index e032108..63cc7fa 100644
--- a/console/linphonec.c
+++ b/console/linphonec.c
@@ -666,10 +666,15 @@ linphonec_init(int argc, char **argv)
#ifndef _WIN32
- snprintf(configfile_name, PATH_MAX, "%s/.linphonerc",
- getenv("HOME"));
- snprintf(zrtpsecrets, PATH_MAX, "%s/.linphone-zidcache",
- getenv("HOME"));
+ char config_dir[PATH_MAX];
+ const char *xdg_config_home = getenv("XDG_CONFIG_HOME");
+ if (xdg_config_home==NULL){
+ snprintf(config_dir, PATH_MAX, "%s/.config/linphone", getenv("HOME"));
+ }else{
+ snprintf(config_dir, PATH_MAX, "%s/linphone", xdg_config_home);
+ }
+ snprintf(configfile_name, PATH_MAX, "%s/linphonerc", config_dir);
+ snprintf(zrtpsecrets, PATH_MAX, "%s/linphone-zidcache", config_dir);
#elif defined(_WIN32_WCE)
strncpy(configfile_name,PACKAGE_DIR "\\linphonerc",PATH_MAX);
mylogfile=fopen(PACKAGE_DIR "\\" "linphonec.log","w");
@@ -1051,6 +1056,9 @@ linphonec_idle_call ()
static int
linphonec_initialize_readline()
{
+ char cache_dir[PATH_MAX];
+ char *xdg_cache_home;
+
/*rl_bind_key('\t', rl_insert);*/
/* Allow conditional parsing of ~/.inputrc */
@@ -1061,8 +1069,12 @@ linphonec_initialize_readline()
rl_event_hook=linphonec_idle_call;
/* Set history file and read it */
- histfile_name = ms_strdup_printf ("%s/.linphonec_history",
- getenv("HOME"));
+ if ((xdg_cache_home=getenv("XDG_CACHE_HOME"))){
+ snprintf(cache_dir, PATH_MAX, "%s/linphone", xdg_cache_home);
+ }else{
+ snprintf(cache_dir, PATH_MAX, "%s/.cache/linphone", getenv("HOME"));
+ }
+ histfile_name = ms_strdup_printf ("%s/linphonec_history", cache_dir);
read_history(histfile_name);
/* Initialized last_in_history cache*/
diff --git a/gtk/main.c b/gtk/main.c
index 73e99cc..a52b706 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -124,13 +124,8 @@ static GOptionEntry linphone_options[]={
#define RELATIVE_XML_DIR
#define BUILD_TREE_XML_DIR "gtk"
-#ifndef WIN32
-#define CONFIG_FILE ".linphonerc"
-#define SECRETS_FILE ".linphone-zidcache"
-#else
#define CONFIG_FILE "linphonerc"
#define SECRETS_FILE "linphone-zidcache"
-#endif
char *linphone_gtk_get_config_file(const char *filename){
@@ -149,9 +144,10 @@ char *linphone_gtk_get_config_file(const char *filename){
snprintf(config_file,path_max,"%s\\%s\\%s",appdata,LINPHONE_CONFIG_DIR,filename);
}
#else
- const char *home=getenv("HOME");
- if (home==NULL) home=".";
- snprintf(config_file,path_max,"%s/%s",home,filename);
+ const char *config_dir=g_get_user_config_dir();
+ snprintf(config_file,path_max,"%s/linphone",config_dir);
+ g_mkdir_with_parents(config_file, 0700);
+ snprintf(config_file,path_max,"%s/linphone/%s",config_dir,filename);
#endif
}
return config_file;
diff --git a/oRTP/src/port.c b/oRTP/src/port.c
index 0f94e16..dd6a600 100644
--- a/oRTP/src/port.c
+++ b/oRTP/src/port.c
@@ -371,13 +371,20 @@ char * WSAAPI gai_strerror(int errnum){
#ifndef WIN32
+#include <stdlib.h>
#include <sys/socket.h>
#include <netdb.h>
#include <sys/un.h>
#include <sys/stat.h>
static char *make_pipe_name(const char *name){
- return ortp_strdup_printf("/tmp/%s",name);
+ char *runtime_dir=getenv("XDG_RUNTIME_DIR");
+ if (runtime_dir==NULL){
+ /* XDG Base Directory Specification mandates this warning. */
+ ortp_warning("XDG_RUNTIME_DIR not set, fallback to /tmp");
+ runtime_dir="/tmp";
+ }
+ return ortp_strdup_printf("%s/%s",runtime_dir,name);
}
/* portable named pipes */

View File

@ -1,6 +1,6 @@
#!/bin/bash
# Build script for Slackware
# Copyright (C) 2010,2011 Damien Goutte-Gattat
# Copyright (C) 2010,2011,2012 Damien Goutte-Gattat
#
# Redistribution and use of this script, with or without modifications,
# is permitted provided that the following conditions are met:
@ -36,7 +36,7 @@ WGET=${WGET:-http://download.savannah.gnu.org/releases/linphone/3.5.x/sources/$A
# Build infos
NAMEPKG=${NAMEPKG:-linphone}
BUILD=${BUILD:-1GGD}
BUILD=${BUILD:-2GGD}
ARCH=${ARCH:-$(uname -m | sed 's/^i.86$/i486/;s/^arm.*/arm/')}
JOBS=${JOBS:-1}
EXT=${EXT:-txz}
@ -87,6 +87,8 @@ cd $TMP
echo "Building $ARCHIVE..."
tar xf $CWD/$ARCHIVE
cd $NAME
# Support for XDG Base Directory Specification
patch -p 1 < $CWD/linphone-3.5.0-xdg-basedir.diff
CFLAGS=$CPUOPT \
CXXFLAGS=$CPUOPT \
./configure \