int mod_sm_init() { if(ioncore_g.sm_client_id!=NULL) mod_sm_set_ion_id(ioncore_g.sm_client_id); if(!mod_sm_init_session()) goto err; if(extl_sessiondir()==NULL) mod_sm_set_sessiondir(); if(!mod_sm_register_exports()) goto err; ioncore_set_sm_callbacks(mod_sm_add_match, mod_sm_get_configuration); hook_add(clientwin_do_manage_alt, (WHookDummy*)sm_do_manage); ioncore_set_smhook(mod_sm_smhook); return TRUE; err: mod_sm_deinit(); return FALSE; }
/*EXTL_DOC * Get important directories (the fields \var{userdir}, * \var{sessiondir}, \var{searchpath} in the returned table). */ EXTL_SAFE EXTL_EXPORT ExtlTab ioncore_get_paths(ExtlTab tab) { tab=extl_create_table(); extl_table_sets_s(tab, "userdir", extl_userdir()); extl_table_sets_s(tab, "sessiondir", extl_sessiondir()); extl_table_sets_s(tab, "searchpath", extl_searchpath()); return tab; }
static void sm_set_other_properties() { char *restore="-session"; char *clientid="-smclientid"; int nvals=0, i; const char *sdir=NULL, *cid=NULL; SmPropValue restart_hint_val, *restart_val=NULL; SmProp restart_hint_prop={ SmRestartStyleHint, SmCARD8, 1, NULL}; SmProp restart_prop={ SmRestartCommand, SmLISTofARRAY8, 0, NULL}; SmProp *props[2]; restart_hint_prop.vals=&restart_hint_val; props[0]=&restart_prop; props[1]=&restart_hint_prop; sdir=extl_sessiondir(); cid=mod_sm_get_ion_id(); if(sdir==NULL || cid==NULL) return; restart_hint_val.value=&restart_hint; restart_hint_val.length=1; restart_val=(SmPropValue *)malloc((ioncore_g.argc+4)*sizeof(SmPropValue)); for(i=0; i<ioncore_g.argc; i++){ if(strcmp(ioncore_g.argv[i], restore)==0 || strcmp(ioncore_g.argv[i], clientid)==0){ i++; }else{ restart_val[nvals].value=ioncore_g.argv[i]; restart_val[nvals++].length=strlen(ioncore_g.argv[i]); } } restart_val[nvals].value=restore; restart_val[nvals++].length=strlen(restore); restart_val[nvals].value=(char*)sdir; restart_val[nvals++].length=strlen(sdir); restart_val[nvals].value=clientid; restart_val[nvals++].length=strlen(clientid); restart_val[nvals].value=(char*)cid; restart_val[nvals++].length=strlen(cid); restart_prop.num_vals=nvals; restart_prop.vals=restart_val; SmcSetProperties(sm_conn, sizeof(props)/sizeof(props[0]), (SmProp **)&props); free(restart_val); }