/* * session.h * * Copyright (C) 1995, 1996, 1997, 1997, 1998, 1999, 2000, 2001, 2002 Kenichi Kourai * Copyright (C) 1999, 2000, 2001, 2002 Luiz Blanes * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with blwm; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /* -*- c++ -*- */ #ifndef SESSION_H_ #define SESSION_H_ #ifdef USE_XSMP #include #include #include #include "list.h" class BlwmProto { char* id; char* role; char* res_class; char* res_name; char* name; int x, y; int width, height; unsigned long flags; public: BlwmProto() { id = role = res_class = res_name = name = NULL; x = y = width = height = 0; flags = 0; } ~BlwmProto() { delete id; delete role; delete res_class; delete res_name; delete name; } void SetId(char* aid) { id = strdup(aid); } void SetRole(char* arole) { role = strdup(arole); } void SetRClass(char* arclass) { res_class = strdup(arclass); } void SetRName(char* arname) { res_name = strdup(arname); } void SetName(char* aname) { name = strdup(aname); } void SetPos(int ax, int ay) { x = ax; y = ay; } void SetSize(int aw, int ah) { width = aw; height = ah; } void SetFlags(unsigned long af) { flags = af; } // <@_@> const char* GetId() const { return id; } const char* GetRole() const { return role; } const char* GetRClass() const { return res_class; } const char* GetRName() const { return res_name; } const char* GetName() const { return name; } int GetX() const { return x; } int GetY() const { return y; } int GetWidth() const { return width; } int GetHeight() const { return height; } unsigned long GetFlags() const { return flags; } // void dump(const char* label); }; class Session { private: static void DieCallback(SmcConn arg_connId, SmPointer client_data); static void SaveCompleteCallback(SmcConn arg_connId, SmPointer client_data); static void ShutdownCancelledCallback(SmcConn arg_connId, SmPointer client_data); static void SaveYourselfPhase2Callback(SmcConn arg_connId, SmPointer client_data); static void SaveYourselfCallback(SmcConn arg_connId, SmPointer client_data, int save_type, Bool shutdown, int interact_style, Bool fast); static void IceConnWatchCallback(IceConn conn, IcePointer client_data, Bool opening, IcePointer* watch_data); FILE* OpenSessionFile(const char* mode); void Die(SmcConn arg_connId); void SaveComplete(SmcConn arg_connId); void ShutdownCancelled(SmcConn arg_connId); void SaveYourselfPhase2(SmcConn arg_connId); void SaveYourself(SmcConn arg_connId, int save_type, Bool shutdown, int interact_style, Bool fast); void IceConnWatch(IceConn conn, Bool opening, IcePointer* watch_data); void InitializeProperties(); Bool ConnectSessionManager(char* arg_previousId); Bool ReadVector(char** p, int* x, int* y); SmcConn connId; char* previousId; char* clientId; char sessionFile[MAXPATHLEN]; int iceConnFd; IceConn iceConn; Bool status; Bool saveDone; List blwmProtoList; // Blwm prototype list public: Session(char* arg_previousId); virtual ~Session(); void CloseConnection(); Bool LoadSessionFile(); Bool SearchProto(const unsigned char* smid, const unsigned char* wm_role, const char* rclass, const char* rname, const char* name, int* x, int* y, int* width, int* height); //static void debug(char* fmt_string, ...); int GetIceConnFd() const { return iceConnFd; } IceConn GetIceConn() const { return iceConn; } Bool GetStatus() const { return status; } Bool RequestQuit(); }; extern Session* session; #endif // USE_XSMP #endif // SESSION_H_