session.h
上传用户:psq1974
上传日期:2007-01-06
资源大小:1195k
文件大小:6k
- /* Copyright (C) 1998, 1999 State University of New York at Stony Brook
- Author: Andrew V. Shuvalov ( andrew@ecsl.cs.sunysb.edu )
- Software license is located in file "COPYING"
- */
- #ifndef _session_h_
- #define _session_h_
- #include <string>
- #include <map>
- #include <gdbm.h>
- #include "vs_types.h"
- #include "word_db.h"
- #include "movie_item.h"
- #include "basic_exception.h"
- #include "preferences.h"
- #include "db_connection.h"
- #include "channel_info.h"
- class PlaybackWindow;
- class SearchSystem;
- class SearchWindow;
- class SuLoginWindow;
- class SuperuserPreferenciesWindow;
- class BroadcastWindow;
- /**
- */
- class Session : public Gtk_Main {
- // vars
- /** gdbm */
- string gdbmMainConfigFile;
- /** name of program */
- string argv0;
- /** setting this value to true does not make you superuser, you still
- have to login to server as superuser */
- bool superuser;
- // windows
- /** keep this pointer to main window */
- MainWindow *mainWindow;
- /** map of text windows */
- textWindowsMapT textWindowsMap;
- PrefWindow *preferencesWindow;
- /** database */
- DbConnection *dbConnection;
- /** text container */
- WordDb *wordDb;
- /** search system. This is not the same as the word database */
- SearchSystem *searchSystem;
- /** search window */
- SearchWindow *searchWindow;
- SuLoginWindow *suLoginWindow;
- SuperuserPreferenciesWindow *suPrefWindow;
- /** playback window */
- PlaybackWindow *playbackWindow;
- /** superuser may look what is broadcasted */
- BroadcastWindow *broadcastWindow;
- public:
- /** some configs
- */
- //@{
- /** path to vclient lib path, f.e. /usr/local/lib/vclient */
- ConfigItemStr homeLibPath;
- ConfigItemStr notLoadedPixmap;
- ConfigItemStr loadedPixmap;
- ConfigItemStr PlayPixmap;
- ConfigItemStr StopPixmap;
- ConfigItemStr RecPixmap;
- ConfigItemStr movieDbServerName;
- ConfigItemInt movieDbServerSock;
- // ConfigItemStr pushVideoServerName;
- // ConfigItemInt pushVideoServerSock; // control sock
- ConfigItemStr best1PushServIP;
- ConfigItemStr best2PushServIP;
- ConfigItemInt inputPushSock; // input of mpeg data
- //ConfigItemInt broadcastChannelNumber;
- //vector< ConfigItemStr * > inputPushBroadcastServer; // optional
- //vector< ConfigItemInt * > inputPushBroadcastSock;
- ConfigItemStr mtvPlayerName;
- ConfigItemStr mtvPlayerArguments;
- ConfigItemStr sihPlugin;
- ConfigItemInt topWindowInitSizeX;
- ConfigItemInt topWindowInitSizeY;
- ConfigItemInt verbose;
- ConfigItemInt vServVerbose;
- ConfigItemInt receiveBufferSize;
- ConfigItemInt receiveBufferLowWaterMark;
- ConfigItemInt receiveBufferHighWaterMark;
- /** store a vector of unified Config items to use in preferences window */
- vector< BaseConfigItem * > configItems;
- //@}
- public:
- Session( int *pargc, char ***pargv );
- /** overload */
- void run();
- /** if this function is not called when the program die - it may be
- very bad, sorry
- */
- void cleanup();
- void loadAllConfig();
- void saveAllConfig();
- /** connect or reconnect to the database server */
- void connect_to_dbserver();
- /** copy data from dbConnection to mainWindow */
- void update_movie_list( const string &dbname );
- const WordDb &get_word_db() const { return *wordDb; }
- /** called by mainWindow */
- const MovieItem &get_movie_by_id( int id ) const;
- /** called by mainWindow */
- void display_movie_text_window( int id, time_t timepos = 0 );
- void display_movie_text_window_go_line( int id, unsigned linenum );
- /** called by mainWindow */
- void edit_preferences();
- /** called by textWindow */
- const TextOfMovieT *get_movie_text( int id );
- /** test */
- bool is_movie_text_loaded( int id );
- /** called by search window */
- const WordOccurencesT &find_word( const string &w ) const {
- return wordDb->find_word( w );
- }
- void find_similar_words( const string &word, GList *similar ) const {
- return wordDb->find_similar_words( word, similar );
- }
- void get_hint_words( const string &word, GList *&similar ) const {
- return wordDb->find_hint_words( word, similar );
- }
- int close_text_window( GdkEventAny *ev );
- void menu_close_text_window( int id );
- void notify_text_win_die( int movieId );
- /** called by textWindow. Stop broadcast at the same time.
- This call first load all data from the database server, then
- look at preference best1PushServID and select the best push server
- that can play this movie. If no best server - select the random one
- */
- void playVideo( TextWindow &tw, struct tm t, int id );
- /** Start broadcast, stop video playback. The channel number must be
- specified
- */
- void playBroadcast( const string &url );
- /** stop playback or broadcast video */
- void stop();
- /** tell database server that this movie should be recorded now */
- void start_recording( int channel_id );
- void stop_recording( int channel_id );
- /** called by playback window */
- void select_text_line_by_time( int movieId, time_t t );
- /** called by broadcast window */
- void fill_channellist( channel_infos_mapT &channel_infos_map );
- ///@name callbacks
- //@{
- /** this is main destroy application callback. called from main window
- */
- void callback_destroy_session();
- /** search text */
- void callback_search();
- void callback_superuser();
- void callback_server_preferences();
- void callback_broadcast();
- //@}
- void loadServerProperties( ServerConfigItemVec &props );
- void saveServerProperties( ServerConfigItemVec &props );
- void login_superuser( string passwd );
- /** called by timeout */
- gint timeout();
- /** display string on debug window */
- void put_message( int debl, const string &msg );
- void put_message( int debl, const char *format, ... );
- };
- class GeneralException : public BasicException {
- public:
- GeneralException( const char *format, ... );
- };
- #endif // _session_h_