2 /* Copyright (C) 2003 Olivier Chapuis
3 * some code taken from the xsm: Copyright 1993, 1998 The Open Group */
5 /* This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 /* A set of functions for implementing a dummy sm. The code is based on xsm */
22 /* ---------------------------- included header files ---------------------- */
30 #include <sys/types.h>
34 #include <X11/Xutil.h>
35 #include <X11/Xproto.h>
36 #include <X11/Xatom.h>
43 /* #define FVWM_DEBUG_FSM */
45 /* ---------------------------- local definitions -------------------------- */
47 /* ---------------------------- local macros ------------------------------- */
49 /* ---------------------------- imports ------------------------------------ */
51 /* ---------------------------- included code files ------------------------ */
53 /* ---------------------------- local types -------------------------------- */
61 /* ---------------------------- forward declarations ----------------------- */
63 /* ---------------------------- local variables ---------------------------- */
65 static FIceAuthDataEntry
*authDataEntries
= NULL
;
66 static FIceIOErrorHandler prev_handler
;
67 static FIceListenObj
*listenObjs
;
69 static char *addAuthFile
= NULL
;
70 static char *remAuthFile
= NULL
;
72 static flist
*fsm_ice_conn_list
= NULL
;
73 static flist
*pending_ice_conn_list
= NULL
;
74 static int numTransports
= 0;
75 static char *networkIds
= NULL
;
76 static int *ice_fd
= NULL
;
78 static char *module_name
= NULL
;
79 static flist
*running_list
= NULL
;
80 static Bool fsm_init_succeed
= False
;
82 static Atom _XA_WM_CLIENT_LEADER
= None
;
83 static Atom _XA_SM_CLIENT_ID
= None
;
85 /* ---------------------------- exported variables (globals) --------------- */
87 /* ---------------------------- local functions ---------------------------- */
94 void free_fsm_client(fsm_client_t
*client
)
101 if (client
->clientId
)
103 free(client
->clientId
);
112 fprintfhex(register FILE *fp
, unsigned int len
, char *cp
)
114 static const char hexchars
[] = "0123456789abcdef";
116 for (; len
> 0; len
--, cp
++) {
117 unsigned char s
= *cp
;
118 putc(hexchars
[s
>> 4], fp
);
119 putc(hexchars
[s
& 0x0f], fp
);
124 * Host Based Authentication Callback. This callback is invoked if
125 * the connecting client can't offer any authentication methods that
126 * we can accept. We can accept/reject based on the hostname.
130 Bool
HostBasedAuthProc(char *hostname
)
132 return (0); /* For now, we don't support host based authentication */
136 * We use temporary files which contain commands to add/remove entries from
137 * the .ICEauthority file.
141 write_iceauth(FILE *addfp
, FILE *removefp
, FIceAuthDataEntry
*entry
)
149 "add %s \"\" %s %s ", entry
->protocol_name
, entry
->network_id
,
151 fprintfhex(addfp
, entry
->auth_data_length
, entry
->auth_data
);
152 fprintf(addfp
, "\n");
156 "remove protoname=%s protodata=\"\" netid=%s authname=%s\n",
157 entry
->protocol_name
, entry
->network_id
, entry
->auth_name
);
162 unique_filename(char *path
, char *prefix
, int *pFd
)
166 tempFile
= (char *)safemalloc(strlen(path
) + strlen(prefix
) + 8);
167 sprintf(tempFile
, "%s/%sXXXXXX", path
, prefix
);
168 *pFd
= fvwm_mkstemp(tempFile
);
178 * Provide authentication data to clients that wish to connect
181 #define MAGIC_COOKIE_LEN 16
184 Status
SetAuthentication(
185 int count
,FIceListenObj
*listenObjs
,FIceAuthDataEntry
**authDataEntries
)
188 FILE *removefp
= NULL
;
200 original_umask
= umask (0077); /* disallow non-owner access */
202 path
= (char *)getenv("SM_SAVE_DIR");
205 path
= getenv("HOME");
213 pwd
= getpwuid(getuid());
224 if ((addAuthFile
= unique_filename (path
, ".fsm-", &fd
)) == NULL
)
228 if (!(addfp
= fdopen(fd
, "wb")))
232 if ((remAuthFile
= unique_filename (path
, ".fsm-", &fd
)) == NULL
)
236 if (!(removefp
= fdopen(fd
, "wb")))
241 *authDataEntries
= (FIceAuthDataEntry
*) safemalloc(
242 count
* 2 * sizeof (FIceAuthDataEntry
));
244 for (i
= 0; i
< count
* 2; i
+= 2)
246 (*authDataEntries
)[i
].network_id
=
247 FIceGetListenConnectionString(listenObjs
[i
/2]);
248 (*authDataEntries
)[i
].protocol_name
= "ICE";
249 (*authDataEntries
)[i
].auth_name
= "MIT-MAGIC-COOKIE-1";
251 (*authDataEntries
)[i
].auth_data
=
252 FIceGenerateMagicCookie (MAGIC_COOKIE_LEN
);
253 (*authDataEntries
)[i
].auth_data_length
= MAGIC_COOKIE_LEN
;
255 (*authDataEntries
)[i
+1].network_id
=
256 FIceGetListenConnectionString(listenObjs
[i
/2]);
257 (*authDataEntries
)[i
+1].protocol_name
= "XSMP";
258 (*authDataEntries
)[i
+1].auth_name
= "MIT-MAGIC-COOKIE-1";
260 (*authDataEntries
)[i
+1].auth_data
=
261 FIceGenerateMagicCookie (MAGIC_COOKIE_LEN
);
262 (*authDataEntries
)[i
+1].auth_data_length
= MAGIC_COOKIE_LEN
;
264 write_iceauth(addfp
, removefp
, &(*authDataEntries
)[i
]);
265 write_iceauth(addfp
, removefp
, &(*authDataEntries
)[i
+1]);
267 FIceSetPaAuthData(2, &(*authDataEntries
)[i
]);
268 FIceSetHostBasedAuthProc(listenObjs
[i
/2], HostBasedAuthProc
);
274 umask (original_umask
);
276 sprintf (command
, "iceauth source %s", addAuthFile
);
279 unlink (addAuthFile
);
297 unlink (addAuthFile
);
302 unlink (remAuthFile
);
310 void FreeAuthenticationData(int count
, FIceAuthDataEntry
*authDataEntries
)
312 /* Each transport has entries for ICE and XSMP */
322 for (i
= 0; i
< count
* 2; i
++)
324 free(authDataEntries
[i
].network_id
);
325 free(authDataEntries
[i
].auth_data
);
328 free ((char *) authDataEntries
);
330 sprintf (command
, "iceauth source %s", remAuthFile
);
333 unlink (remAuthFile
);
344 void MyIoErrorHandler(FIceConn ice_conn
)
353 (*prev_handler
) (ice_conn
);
358 void InstallIOErrorHandler(void)
360 FIceIOErrorHandler default_handler
;
367 prev_handler
= FIceSetIOErrorHandler(NULL
);
368 default_handler
= FIceSetIOErrorHandler(MyIoErrorHandler
);
369 if (prev_handler
== default_handler
)
383 FIceFreeListenObjs(numTransports
, listenObjs
);
388 FIceConn conn
, FIcePointer client_data
, Bool opening
,
389 FIcePointer
*watch_data
)
391 fsm_ice_conn_t
*fice_conn
;
400 fice_conn
= (fsm_ice_conn_t
*)safemalloc(sizeof(fsm_ice_conn_t
));
401 fice_conn
->ice_conn
= conn
;
402 fice_conn
->fd
= FIceConnectionNumber(conn
);
403 *watch_data
= (FIcePointer
) fice_conn
;
405 flist_append_obj(fsm_ice_conn_list
, fice_conn
);
406 fcntl(fice_conn
->fd
, F_SETFD
, FD_CLOEXEC
);
410 fice_conn
= (fsm_ice_conn_t
*)*watch_data
;
412 flist_remove_obj(fsm_ice_conn_list
, fice_conn
);
418 * Session Manager callbacks
422 Status
RegisterClientProc(
423 FSmsConn smsConn
, FSmPointer managerData
, char *previousId
)
425 fsm_client_t
*client
= (fsm_client_t
*) managerData
;
433 #ifdef FVWM_DEBUG_FSM
435 "[%s][RegisterClientProc] On FIceConn fd = %d, received "
436 "REGISTER CLIENT [Previous Id = %s]\n", module_name
,
437 FIceConnectionNumber (client
->ice_conn
),
438 previousId
? previousId
: "NULL");
441 /* ignore previousID!! (we are dummy) */
442 id
= FSmsGenerateClientID(smsConn
);
443 if (!FSmsRegisterClientReply(smsConn
, id
))
445 /* cannot happen ? */
452 "[%s][RegisterClientProc] ERR -- fail to register "
453 "client", module_name
);
457 #ifdef FVWM_DEBUG_FSM
459 "[%s][RegisterClientProc] On FIceConn fd = %d, sent "
460 "REGISTER CLIENT REPLY [Client Id = %s]\n",
461 module_name
, FIceConnectionNumber (client
->ice_conn
), id
);
464 client
->clientId
= id
;
465 /* client->clientHostname = FSmsClientHostName (smsConn); */
467 /* we are dummy ... do not do that */
471 smsConn
, FSmSaveLocal
, False
, FSmInteractStyleNone
,
479 InteractRequestProc(FSmsConn smsConn
, FSmPointer managerData
, int dialogType
)
485 /* no intercation! */
487 FSmsInteract (client
->smsConn
);
493 InteractDoneProc(FSmsConn smsConn
, FSmPointer managerData
, Bool cancelShutdown
)
495 /* no intercation! */
499 SaveYourselfReqProc(FSmsConn smsConn
, FSmPointer managerData
, int saveType
,
500 Bool shutdown
, int interactStyle
, Bool fast
, Bool global
)
502 /* no session to save */
506 void SaveYourselfPhase2ReqProc(FSmsConn smsConn
, FSmPointer managerData
)
508 fsm_client_t
*client
;
514 client
= (fsm_client_t
*)managerData
;
515 FSmsSaveYourselfPhase2(client
->smsConn
);
519 SaveYourselfDoneProc(FSmsConn smsConn
, FSmPointer managerData
, Bool success
)
521 fsm_client_t
*client
;
527 client
= (fsm_client_t
*) managerData
;
528 FSmsSaveComplete(client
->smsConn
);
532 CloseDownClient(fsm_client_t
*client
)
540 #ifdef FVWM_DEBUG_FSM
542 stderr
, "[%s][CloseDownClient] ICE Connection closed, "
543 "FIceConn fd = %d\n", module_name
,
544 FIceConnectionNumber (client
->ice_conn
));
547 FSmsCleanUp(client
->smsConn
);
548 FIceSetShutdownNegotiation(client
->ice_conn
, False
);
549 if (!FIceCloseConnection(client
->ice_conn
) != FIceClosedNow
)
554 client
->ice_conn
= NULL
;
555 client
->smsConn
= NULL
;
557 running_list
= flist_remove_obj(running_list
, client
);
558 free_fsm_client(client
);
562 CloseConnectionProc(FSmsConn smsConn
, FSmPointer managerData
,
563 int count
, char **reasonMsgs
)
565 fsm_client_t
*client
= (fsm_client_t
*) managerData
;
571 FSmFreeReasons(count
, reasonMsgs
);
572 CloseDownClient(client
);
576 void SetPropertiesProc(
577 FSmsConn smsConn
, FSmPointer managerData
, int numProps
, FSmProp
**props
)
585 for (i
= 0; i
< numProps
; i
++)
587 FSmFreeProperty(props
[i
]);
589 free ((char *) props
);
593 void DeletePropertiesProc(
594 FSmsConn smsConn
, FSmPointer managerData
, int numProps
, char **propNames
)
602 for (i
= 0; i
< numProps
; i
++)
606 free ((char *) propNames
);
610 void GetPropertiesProc(FSmsConn smsConn
, FSmPointer managerData
)
616 FSmsConn smsConn
, FSmPointer managerData
, unsigned long *maskRet
,
617 FSmsCallbacks
*callbacksRet
, char **failureReasonRet
)
626 nc
= (fsm_client_t
*)safemalloc(sizeof (fsm_client_t
));
629 nc
->smsConn
= smsConn
;
630 nc
->ice_conn
= FSmsGetIceConnection(smsConn
);
633 running_list
= flist_append_obj(running_list
, nc
);
635 #ifdef FVWM_DEBUG_FSM
637 stderr
, "[%s][NewClientProc] On FIceConn fd = %d, client "
638 "set up session mngmt protocol\n", module_name
,
639 FIceConnectionNumber (nc
->ice_conn
));
643 * Set up session manager callbacks.
646 *maskRet
|= FSmsRegisterClientProcMask
;
647 callbacksRet
->register_client
.callback
= RegisterClientProc
;
648 callbacksRet
->register_client
.manager_data
= (FSmPointer
) nc
;
650 *maskRet
|= FSmsInteractRequestProcMask
;
651 callbacksRet
->interact_request
.callback
= InteractRequestProc
;
652 callbacksRet
->interact_request
.manager_data
= (FSmPointer
) nc
;
654 *maskRet
|= FSmsInteractDoneProcMask
;
655 callbacksRet
->interact_done
.callback
= InteractDoneProc
;
656 callbacksRet
->interact_done
.manager_data
= (FSmPointer
) nc
;
658 *maskRet
|= FSmsSaveYourselfRequestProcMask
;
659 callbacksRet
->save_yourself_request
.callback
= SaveYourselfReqProc
;
660 callbacksRet
->save_yourself_request
.manager_data
= (FSmPointer
) nc
;
662 *maskRet
|= FSmsSaveYourselfP2RequestProcMask
;
663 callbacksRet
->save_yourself_phase2_request
.callback
=
664 SaveYourselfPhase2ReqProc
;
665 callbacksRet
->save_yourself_phase2_request
.manager_data
=
668 *maskRet
|= FSmsSaveYourselfDoneProcMask
;
669 callbacksRet
->save_yourself_done
.callback
= SaveYourselfDoneProc
;
670 callbacksRet
->save_yourself_done
.manager_data
= (FSmPointer
) nc
;
672 *maskRet
|= FSmsCloseConnectionProcMask
;
673 callbacksRet
->close_connection
.callback
= CloseConnectionProc
;
674 callbacksRet
->close_connection
.manager_data
= (FSmPointer
) nc
;
676 *maskRet
|= FSmsSetPropertiesProcMask
;
677 callbacksRet
->set_properties
.callback
= SetPropertiesProc
;
678 callbacksRet
->set_properties
.manager_data
= (FSmPointer
) nc
;
680 *maskRet
|= FSmsDeletePropertiesProcMask
;
681 callbacksRet
->delete_properties
.callback
= DeletePropertiesProc
;
682 callbacksRet
->delete_properties
.manager_data
= (FSmPointer
) nc
;
684 *maskRet
|= FSmsGetPropertiesProcMask
;
685 callbacksRet
->get_properties
.callback
= GetPropertiesProc
;
686 callbacksRet
->get_properties
.manager_data
= (FSmPointer
) nc
;
696 void CompletNewConnectionMsg(void)
698 flist
*l
= pending_ice_conn_list
;
700 Bool pending
= False
;
701 FIceAcceptStatus cstatus
;
710 ice_conn
= (FIceConn
)l
->object
;
711 cstatus
= FIceConnectionStatus(ice_conn
);
712 if (cstatus
== FIceConnectPending
)
717 else if (cstatus
== FIceConnectAccepted
)
720 pending_ice_conn_list
=
722 pending_ice_conn_list
,
724 #ifdef FVWM_DEBUG_FSM
727 connstr
= FIceConnectionString (ice_conn
);
728 fprintf(stderr
, "[%s][NewConnection] ICE Connection "
729 "opened by client, FIceConn fd = %d, Accept at "
730 "networkId %s\n", module_name
,
731 FIceConnectionNumber (ice_conn
), connstr
);
737 if (FIceCloseConnection (ice_conn
) != FIceClosedNow
)
741 pending_ice_conn_list
=
743 pending_ice_conn_list
,
745 #ifdef FVWM_DEBUG_FSM
746 if (cstatus
== FIceConnectIOError
)
748 fprintf(stderr
, "[%s][NewConnection] IO error "
749 "opening ICE Connection!\n",
754 fprintf(stderr
, "[%s][NewConnection] ICE "
755 "Connection rejected!\n",
764 void NewConnectionMsg(int i
)
767 FIceAcceptStatus status
;
775 ice_conn
= FIceAcceptConnection(listenObjs
[i
], &status
);
776 #ifdef FVWM_DEBUG_FSM
777 fprintf(stderr
, "[%s][NewConnection] %i\n", module_name
, i
);
781 #ifdef FVWM_DEBUG_FSM
782 fprintf(stderr
, "[%s][NewConnection] "
783 "FIceAcceptConnection failed\n", module_name
);
788 pending_ice_conn_list
=
789 flist_append_obj(pending_ice_conn_list
, ice_conn
);
791 CompletNewConnectionMsg();
796 void ProcessIceMsg(fsm_ice_conn_t
*fic
)
798 FIceProcessMessagesStatus status
;
805 #ifdef FVWM_DEBUG_FSM
806 fprintf(stderr
, "[%s][ProcessIceMsg] %i\n", module_name
, (int)fic
->fd
);
809 status
= FIceProcessMessages(fic
->ice_conn
, NULL
, NULL
);
811 if (status
== FIceProcessMessagesIOError
)
816 #ifdef FVWM_DEBUG_FSM
817 fprintf(stderr
, "[%s][ProcessIceMsg] IO error on connection\n",
821 for (cl
= running_list
; cl
; cl
= cl
->next
)
823 fsm_client_t
*client
= (fsm_client_t
*) cl
->object
;
825 if (client
->ice_conn
== fic
->ice_conn
)
827 CloseDownClient (client
);
836 * The client must have disconnected before it was added
837 * to the session manager's running list (i.e. before the
838 * NewClientProc callback was invoked).
841 FIceSetShutdownNegotiation (fic
->ice_conn
, False
);
842 if (!FIceCloseConnection(fic
->ice_conn
) != FIceClosedNow
)
854 char *GetClientID(Display
*dpy
, Window window
)
856 char *client_id
= NULL
;
857 Window client_leader
= None
;
861 unsigned long nitems
;
862 unsigned long bytes_after
;
863 unsigned char *prop
= NULL
;
870 if (!_XA_WM_CLIENT_LEADER
)
872 _XA_WM_CLIENT_LEADER
= XInternAtom(
873 dpy
, "WM_CLIENT_LEADER", False
);
875 if (!_XA_SM_CLIENT_ID
)
877 _XA_SM_CLIENT_ID
= XInternAtom(dpy
, "SM_CLIENT_ID", False
);
880 if (XGetWindowProperty(
881 dpy
, window
, _XA_WM_CLIENT_LEADER
, 0L, 1L, False
,
882 AnyPropertyType
, &actual_type
, &actual_format
, &nitems
,
883 &bytes_after
, &prop
) == Success
)
885 if (actual_type
== XA_WINDOW
&& actual_format
== 32 &&
886 nitems
== 1 && bytes_after
== 0)
888 client_leader
= (Window
)(*(long *)prop
);
894 client_leader
= window
;
899 if (XGetTextProperty(dpy
, client_leader
, &tp
, _XA_SM_CLIENT_ID
))
901 if (tp
.encoding
== XA_STRING
&& tp
.format
== 8 &&
904 client_id
= (char *) tp
.value
;
918 void set_session_manager(Display
*dpy
, Window window
, char *sm
)
920 Window client_leader
= None
;
923 unsigned long nitems
;
924 unsigned long bytes_after
;
925 unsigned char *prop
= NULL
;
927 static Atom _XA_SESSION_MANAGER
= None
;
936 if (!_XA_SESSION_MANAGER
)
938 _XA_SESSION_MANAGER
= XInternAtom (
939 dpy
, "SESSION_MANAGER", False
);
941 if (!_XA_WM_CLIENT_LEADER
)
943 _XA_WM_CLIENT_LEADER
= XInternAtom(
944 dpy
, "WM_CLIENT_LEADER", False
);
946 if (!_XA_SM_CLIENT_ID
)
948 _XA_SM_CLIENT_ID
= XInternAtom(dpy
, "SM_CLIENT_ID", False
);
951 if (XGetWindowProperty(
952 dpy
, window
, _XA_WM_CLIENT_LEADER
, 0L, 1L, False
,
953 AnyPropertyType
, &actual_type
, &actual_format
, &nitems
,
954 &bytes_after
, &prop
) == Success
)
956 if (actual_type
== XA_WINDOW
&& actual_format
== 32 &&
957 nitems
== 1 && bytes_after
== 0)
959 client_leader
= (Window
)(*(long *)prop
);
965 client_leader
= window
;
968 #ifdef FVWM_DEBUG_FSM
970 stderr
, "[%s][fsm_init] Proxy %s window 0x%lx\n",
971 module_name
, (sm
)? "On":"Off", client_leader
);
975 /* set the client id for ksmserver */
979 dpy
, client_leader
, _XA_SESSION_MANAGER
, XA_STRING
,
980 8, PropModeReplace
, (unsigned char *)sm
, strlen(sm
));
982 dpy
, client_leader
, _XA_SM_CLIENT_ID
, XA_STRING
,
983 8, PropModeReplace
, (unsigned char *)dummy_id
,
988 XDeleteProperty(dpy
, client_leader
, _XA_SESSION_MANAGER
);
989 XDeleteProperty(dpy
, client_leader
, _XA_SM_CLIENT_ID
);
993 /* ---------------------------- interface functions ------------------------ */
995 int fsm_init(char *module
)
1001 if (!SessionSupport
)
1004 MyIoErrorHandler(NULL
);
1005 HostBasedAuthProc(NULL
);
1006 ice_watch_fd(0, NULL
, 0, NULL
);
1007 NewClientProc(0, NULL
, 0, NULL
, NULL
);
1008 #ifdef FVWM_DEBUG_FSM
1010 stderr
, "[%s][fsm_init] No Session Support\n",
1016 if (fsm_init_succeed
)
1019 stderr
, "[%s][fsm_init] <<ERROR>> -- "
1020 "Session already Initialized!\n", module_name
);
1023 module_name
= module
;
1024 InstallIOErrorHandler ();
1026 #ifdef FVWM_DEBUG_FSM
1027 fprintf(stderr
, "[%s][fsm_init] FSmsInitialize\n", module_name
);
1029 if (!FSmsInitialize(
1030 module
, "1.0", NewClientProc
, NULL
, HostBasedAuthProc
, 256,
1034 stderr
, "[%s][fsm_init] <<ERROR>> -- "
1035 "FSmsInitialize failed: %s\n",
1036 module_name
, errormsg
);
1040 if (!FIceListenForConnections (
1041 &numTransports
, &listenObjs
, 256, errormsg
))
1044 stderr
, "[%s][fsm_init] <<ERROR>> -- "
1045 "FIceListenForConnections failed:\n"
1046 "%s\n", module_name
, errormsg
);
1050 atexit(CloseListeners
);
1052 if (!SetAuthentication(numTransports
, listenObjs
, &authDataEntries
))
1055 stderr
, "[%s][fsm_init] <<ERROR>> -- "
1056 "Could not set authorization\n", module_name
);
1060 if (FIceAddConnectionWatch(&ice_watch_fd
, NULL
) == 0)
1063 "[%s][fsm_init] <<ERROR>> -- "
1064 "FIceAddConnectionWatch failed\n", module_name
);
1068 ice_fd
= (int *)safemalloc(sizeof(int) * numTransports
+ 1);
1069 for (i
= 0; i
< numTransports
; i
++)
1071 ice_fd
[i
] = FIceGetListenConnectionNumber(listenObjs
[i
]);
1074 networkIds
= FIceComposeNetworkIdList(numTransports
, listenObjs
);
1075 p
= (char *)safemalloc(
1076 16 + strlen(networkIds
) + 1);
1077 sprintf(p
, "SESSION_MANAGER=%s", networkIds
);
1080 #ifdef FVWM_DEBUG_FSM
1081 fprintf(stderr
,"[%s][fsm_init] OK: %i\n", module_name
, numTransports
);
1082 fprintf(stderr
,"\t%s\n", p
);
1085 fsm_init_succeed
= True
;
1089 void fsm_fdset(fd_set
*in_fdset
)
1092 flist
*l
= fsm_ice_conn_list
;
1093 fsm_ice_conn_t
*fic
;
1095 if (!SessionSupport
|| !fsm_init_succeed
)
1100 for (i
= 0; i
< numTransports
; i
++)
1102 FD_SET(ice_fd
[i
], in_fdset
);
1106 fic
= (fsm_ice_conn_t
*)l
->object
;
1107 FD_SET(fic
->fd
, in_fdset
);
1113 Bool
fsm_process(fd_set
*in_fdset
)
1116 flist
*l
= fsm_ice_conn_list
;
1117 fsm_ice_conn_t
*fic
;
1119 if (!SessionSupport
|| !fsm_init_succeed
)
1124 if (pending_ice_conn_list
!= NULL
)
1126 CompletNewConnectionMsg();
1130 fic
= (fsm_ice_conn_t
*)l
->object
;
1131 if (FD_ISSET(fic
->fd
, in_fdset
))
1137 for (i
= 0; i
< numTransports
; i
++)
1139 if (FD_ISSET(ice_fd
[i
], in_fdset
))
1141 NewConnectionMsg(i
);
1144 if (pending_ice_conn_list
!= NULL
)
1151 /* this try to explain to ksmserver and various sm poxies that they should not
1152 * connect our non XSMP award leader window to the top level sm */
1153 void fsm_proxy(Display
*dpy
, Window win
, char *sm
)
1156 flist
*l
= running_list
;
1159 if (!SessionSupport
|| !fsm_init_succeed
)
1164 client_id
= GetClientID(dpy
, win
);
1166 if (client_id
!= NULL
&& strcmp("0", client_id
) != 0)
1168 for (l
= running_list
; l
; l
= l
->next
)
1170 fsm_client_t
*client
= (fsm_client_t
*) l
->object
;
1172 if (client
->clientId
&&
1173 strcmp(client
->clientId
, client_id
) == 0)
1186 set_session_manager(dpy
, win
, sm
);
1189 void fsm_close(void)
1191 if (!SessionSupport
|| !fsm_init_succeed
)
1195 FreeAuthenticationData(numTransports
, authDataEntries
);