📄 hostinfo.c
字号:
if ( (!wkey) || (!hkey) ) return -EINVAL; dbg_out("gconf set size:(%s,%s)=(%d,%d)\n",wkey,hkey,width,height); g_static_mutex_lock(&hostinfo_mutex); gconf_client_set_int(client,wkey,width,NULL); gconf_client_set_int(client,hkey,height,NULL); gconf_client_clear_cache(client); rwidth=gconf_client_get_int(client,wkey,NULL); rheight=gconf_client_get_int(client,hkey,NULL); g_static_mutex_unlock(&hostinfo_mutex); dbg_out("gconf get size:(%s,%s)=(%d,%d)\n",wkey,hkey,rwidth,rheight); return 0;}int hostinfo_get_ipmsg_message_window_size(gint *width,gint *height){ int rc; if ( (!width) || (!height) ) return -EINVAL; rc=hostinfo_get_ipmsg_window_size(HOSTINFO_KEY_MSGWIN_WIDTH, HOSTINFO_KEY_MSGWIN_HEIGHT, width, height); dbg_out("gconf return size:(%d,%d)\n",*width,*height); return rc;}int hostinfo_set_ipmsg_message_window_size(gint width,gint height){ int rc; dbg_out("gconf set size:(%d,%d)\n",width,height); rc=hostinfo_set_ipmsg_window_size(HOSTINFO_KEY_MSGWIN_WIDTH, HOSTINFO_KEY_MSGWIN_HEIGHT, width, height); return rc;}int hostinfo_get_ipmsg_recv_window_size(gint *width,gint *height){ int rc; if ( (!width) || (!height) ) return -EINVAL; rc=hostinfo_get_ipmsg_window_size(HOSTINFO_KEY_RECVWIN_WIDTH, HOSTINFO_KEY_RECVWIN_HEIGHT, width, height); dbg_out("gconf return size:(%d,%d)\n",*width,*height); return rc;}int hostinfo_set_ipmsg_recv_window_size(gint width,gint height){ int rc; dbg_out("gconf set size:(%d,%d)\n",width,height); rc=hostinfo_set_ipmsg_window_size(HOSTINFO_KEY_RECVWIN_WIDTH, HOSTINFO_KEY_RECVWIN_HEIGHT, width, height); return rc;}int hostinfo_get_ipmsg_attach_editor_size(gint *width,gint *height){ int rc; if ( (!width) || (!height) ) return -EINVAL; rc=hostinfo_get_ipmsg_window_size(HOSTINFO_KEY_ATTACHWIN_WIDTH, HOSTINFO_KEY_ATTACHWIN_HEIGHT, width, height); dbg_out("gconf return size:(%d,%d)\n",*width,*height); return rc;}int hostinfo_set_ipmsg_attach_editor_size(gint width,gint height){ int rc; dbg_out("gconf set size:(%d,%d)\n",width,height); rc=hostinfo_set_ipmsg_window_size(HOSTINFO_KEY_ATTACHWIN_WIDTH, HOSTINFO_KEY_ATTACHWIN_HEIGHT, width, height); return rc;}int hostinfo_get_ipmsg_absence_editor_size(gint *width,gint *height){ int rc; if ( (!width) || (!height) ) return -EINVAL; rc=hostinfo_get_ipmsg_window_size(HOSTINFO_KEY_ABSENCE_WIDTH, HOSTINFO_KEY_ABSENCE_HEIGHT, width, height); dbg_out("gconf return size:(%d,%d)\n",*width,*height); return rc;}int hostinfo_set_ipmsg_absence_editor_size(gint width,gint height){ int rc; dbg_out("gconf set size:(%d,%d)\n",width,height); rc=hostinfo_set_ipmsg_window_size(HOSTINFO_KEY_ABSENCE_WIDTH, HOSTINFO_KEY_ABSENCE_HEIGHT, width, height); return rc;}int hostinfo_get_ipmsg_system_addr_family(void){ if (gconf_client_get_bool(client,HOSTINFO_KEY_IPV6,NULL)) return AF_INET6; else return AF_INET; /* デフォルトはIPV4 */}gboolean is_sound_system_available(void){#if defined(HAVE_GST) return TRUE;#else return FALSE;#endif /* HAVE_GST */}static int update_cached_prio(void) { GSList *conf_top,*conf_list; GSList *conf_ref; conf_list=cached_prio; while(conf_list != NULL) { gchar *element = conf_list->data; if (element) g_free(element); conf_list=g_slist_next(conf_list); } if (cached_prio) g_slist_free(conf_top); cached_prio=conf_list=gconf_client_get_list(client,HOSTINFO_KEY_DEFAULT_PRIO,GCONF_VALUE_STRING,NULL);}inthostinfo_update_ipmsg_ipaddr_prio(const char *ipaddr,int prio){ int rc=0; GSList *conf_top,*conf_list; GSList *conf_ref; gchar *addr; gchar *prio_str; gchar buff[1024]; if (!ipaddr) return -EINVAL; conf_top=conf_list=gconf_client_get_list(client,HOSTINFO_KEY_DEFAULT_PRIO,GCONF_VALUE_STRING,NULL); memset(buff,0,1024); snprintf(buff,1023,"%d%c%s",prio,HOSTINFO_PRIO_SEPARATOR,ipaddr); buff[1023]='\0'; for(conf_ref=conf_top;conf_ref;conf_ref=g_slist_next(conf_ref)) { if (conf_ref->data) { prio_str=conf_ref->data; /* 優先度@アドレスの形式 */ dbg_out("Addr-info:%s\n",prio_str); addr=strchr(prio_str,HOSTINFO_PRIO_SEPARATOR); g_assert(addr); ++addr; if (!strcmp(addr,ipaddr)) { g_free(conf_ref->data); conf_ref->data=strdup(buff); if (!conf_ref->data) { rc=-ENOMEM; goto free_list_out; } dbg_out("Replace prio:%s\n",conf_ref->data); goto start_config; } } } prio_str=strdup(buff); if (!prio_str) { rc=-ENOMEM; goto free_list_out; } conf_top=g_slist_append(conf_top,prio_str); start_config: gconf_client_set_list(client,HOSTINFO_KEY_DEFAULT_PRIO,GCONF_VALUE_STRING,conf_top,NULL); gconf_client_clear_cache(client); rc=0; update_cached_prio(); free_list_out: conf_list=conf_top; while(conf_list != NULL) { gchar *element = conf_list->data; if (element) g_free(element); conf_list=g_slist_next(conf_list); } if (conf_top) g_slist_free(conf_top); return rc;}inthostinfo_get_ipmsg_ipaddr_prio(const char *ipaddr,int *prio){ GSList *conf_top,*conf_list; GSList *conf_ref; gchar *addr; gchar *tmp_str; gchar *prio_str; int val=0; if ( (!ipaddr) || (!prio) ) return -EINVAL; if (!cached_prio) update_cached_prio(); conf_top=cached_prio; for(conf_ref=conf_top;conf_ref;conf_ref=g_slist_next(conf_ref)) { if (conf_ref->data) { prio_str=strdup(conf_ref->data); if (!prio_str) { *prio=0; /* FIXME */ return -ENOMEM; } /* 優先度@アドレスの形式 */ dbg_out("Addr-info:%s\n",prio_str); addr=strchr(prio_str,HOSTINFO_PRIO_SEPARATOR); g_assert(addr); *addr='\0'; ++addr; if (!strcmp(addr,ipaddr)) { val=strtol(prio_str, (char **)NULL, 10); if (prio_is_valid(val)) { dbg_out("default prio:%d (%s)\n",val,addr); } else { dbg_out("default prio invalid :%s\n",addr); val=0; } g_free(prio_str); break; } g_free(prio_str); } } *prio=val; return 0;}gboolean hostinfo_refer_enable_systray(void){ if (!client) return FALSE; return gconf_client_get_bool(client,HOSTINFO_KEY_USE_SYSTRAY,NULL);}gboolean hostinfo_set_enable_systray(gboolean val){ gboolean rc; uint state; g_static_mutex_lock(&hostinfo_mutex); rc=gconf_client_set_bool(client,HOSTINFO_KEY_HEADER_VISIBLE,val,NULL); gconf_client_clear_cache(client); state=gconf_client_get_int(client,HOSTINFO_KEY_HEADER_VISIBLE,NULL); dbg_out("Set header:%x \n",state); g_static_mutex_unlock(&hostinfo_mutex); return rc;}guinthostinfo_refer_header_state(void){ guint state; g_static_mutex_lock(&hostinfo_mutex); state=gconf_client_get_int(client,HOSTINFO_KEY_HEADER_VISIBLE,NULL); dbg_out("Header:%x \n",state); g_static_mutex_unlock(&hostinfo_mutex); return state;}gboolean hostinfo_set_header_state(guint val){ guint state; g_static_mutex_lock(&hostinfo_mutex); gconf_client_set_int(client,HOSTINFO_KEY_HEADER_VISIBLE,val,NULL); gconf_client_clear_cache(client); g_static_mutex_unlock(&hostinfo_mutex);}inthostinfo_get_header_order(int index,int *col_id){ int rc=0; GSList *header_top; GSList *header_ref; if ( (index<0) || (index>=MAX_VIEW_ID) ) return -EINVAL; if (!col_id) return -EINVAL; header_top=gconf_client_get_list(client,HOSTINFO_KEY_HEADER_ORDER,GCONF_VALUE_INT,NULL); if (!header_top) return -ESRCH; rc=-ESRCH; header_ref=g_slist_nth(header_top,index); if (!header_ref) goto free_list_out; *col_id=(int)header_ref->data; gconf_client_set_list(client,HOSTINFO_KEY_HEADER_ORDER,GCONF_VALUE_INT,header_top,NULL); gconf_client_clear_cache(client); rc=0; free_list_out: if (header_top) g_slist_free(header_top); return rc;}inthostinfo_set_ipmsg_header_order(int index,int col_id){ int rc=0; GSList *header_top; GSList *header_ref; if ( (index<0) || (index>=MAX_VIEW_ID) ) return -EINVAL; header_top=gconf_client_get_list(client,HOSTINFO_KEY_HEADER_ORDER,GCONF_VALUE_INT,NULL); if (!header_top) return -ESRCH; rc=-ESRCH; header_ref=g_slist_nth(header_top,index); if (!header_ref) goto free_list_out; header_ref->data=(gpointer)col_id; gconf_client_set_list(client,HOSTINFO_KEY_HEADER_ORDER,GCONF_VALUE_INT,header_top,NULL); gconf_client_clear_cache(client); rc=0; free_list_out: if (header_top) g_slist_free(header_top); return rc;}inthostinfo_init_hostinfo(void){ int i; client = gconf_client_get_default (); gconf_client_add_dir (client, PATH, GCONF_CLIENT_PRELOAD_NONE, NULL); /* * Add keys */ for(i=0;keys[i];++i) { dbg_out("Add %s\n",keys[i]); gconf_client_notify_add (client, keys[i], hostinfo_gconf_notify_func, (gpointer)keys[i], NULL, NULL); } return 0;}voidhostinfo_cleanup_hostinfo(void){ if (groupname) g_free(groupname); if (nickname) g_free(nickname); if (groupname_proto) g_free(groupname_proto); if (nickname_proto) g_free(nickname_proto); if (hostname) g_free(hostname); if (cite_string) g_free(cite_string);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -