session.h
上传用户:psq1974
上传日期:2007-01-06
资源大小:1195k
文件大小:6k
源码类别:

mpeg/mp3

开发平台:

C/C++

  1. /* Copyright (C) 1998, 1999 State University of New York at Stony Brook
  2.    Author: Andrew V. Shuvalov ( andrew@ecsl.cs.sunysb.edu )
  3.    Software license is located in file "COPYING"
  4. */
  5. #ifndef _session_h_
  6. #define _session_h_
  7. #include <string>
  8. #include <map>
  9. #include <gdbm.h>
  10. #include "vs_types.h"
  11. #include "word_db.h"
  12. #include "movie_item.h"
  13. #include "basic_exception.h"
  14. #include "preferences.h"
  15. #include "db_connection.h"
  16. #include "channel_info.h"
  17. class PlaybackWindow;
  18. class SearchSystem;
  19. class SearchWindow;
  20. class SuLoginWindow;
  21. class SuperuserPreferenciesWindow;
  22. class BroadcastWindow;
  23. /** 
  24.  */
  25. class Session : public Gtk_Main {
  26.   // vars
  27.   /** gdbm */
  28.   string gdbmMainConfigFile;
  29.   /** name of program */
  30.   string argv0;
  31.   /** setting this value to true does not make you superuser, you still
  32.       have to login to server as superuser */
  33.   bool superuser;
  34.   // windows
  35.   /** keep this pointer to main window */
  36.   MainWindow *mainWindow;
  37.   /** map of text windows */
  38.   textWindowsMapT textWindowsMap;
  39.   PrefWindow *preferencesWindow;
  40.   /** database */
  41.   DbConnection *dbConnection;
  42.   /** text container */
  43.   WordDb *wordDb;
  44.   /** search system. This is not the same as the word database */
  45.   SearchSystem *searchSystem;
  46.   /** search window */
  47.   SearchWindow *searchWindow;
  48.   SuLoginWindow *suLoginWindow;
  49.   SuperuserPreferenciesWindow *suPrefWindow;
  50.   /** playback window */
  51.   PlaybackWindow *playbackWindow;
  52.   /** superuser may look what is broadcasted */
  53.   BroadcastWindow *broadcastWindow;
  54. public:
  55.   /**  some configs
  56.    */
  57.   //@{
  58.   /** path to vclient lib path, f.e. /usr/local/lib/vclient */
  59.   ConfigItemStr homeLibPath;
  60.   ConfigItemStr notLoadedPixmap;
  61.   ConfigItemStr loadedPixmap;
  62.   ConfigItemStr PlayPixmap;
  63.   ConfigItemStr StopPixmap;
  64.   ConfigItemStr RecPixmap;
  65.   ConfigItemStr movieDbServerName;
  66.   ConfigItemInt movieDbServerSock;
  67.   // ConfigItemStr pushVideoServerName;
  68.   // ConfigItemInt pushVideoServerSock; // control sock
  69.   ConfigItemStr best1PushServIP;
  70.   ConfigItemStr best2PushServIP;
  71.   ConfigItemInt inputPushSock;       // input of mpeg data
  72.   //ConfigItemInt broadcastChannelNumber;
  73.   //vector< ConfigItemStr * > inputPushBroadcastServer; // optional
  74.   //vector< ConfigItemInt * > inputPushBroadcastSock;
  75.   ConfigItemStr mtvPlayerName;
  76.   ConfigItemStr mtvPlayerArguments;
  77.   ConfigItemStr sihPlugin;
  78.   ConfigItemInt topWindowInitSizeX;
  79.   ConfigItemInt topWindowInitSizeY;
  80.   ConfigItemInt verbose;
  81.   ConfigItemInt vServVerbose;
  82.   ConfigItemInt receiveBufferSize;
  83.   ConfigItemInt receiveBufferLowWaterMark;
  84.   ConfigItemInt receiveBufferHighWaterMark;
  85.   /** store a vector of unified Config items to use in preferences window */
  86.   vector< BaseConfigItem * > configItems;
  87.   //@}
  88. public:
  89.   Session( int *pargc, char ***pargv );
  90.   /** overload */
  91.   void run();
  92.   /** if this function is not called when the program die - it may be 
  93.       very bad, sorry 
  94.   */
  95.   void cleanup();
  96.   void loadAllConfig();
  97.   void saveAllConfig();
  98.   /** connect or reconnect to the database server */
  99.   void connect_to_dbserver();
  100.   /** copy data from dbConnection to mainWindow */
  101.   void update_movie_list( const string &dbname );
  102.   const WordDb &get_word_db() const { return *wordDb; }
  103.   /** called by mainWindow */
  104.   const MovieItem &get_movie_by_id( int id ) const;
  105.   /** called by mainWindow */
  106.   void display_movie_text_window( int id, time_t timepos = 0 );
  107.   void display_movie_text_window_go_line( int id, unsigned linenum );
  108.   /** called by mainWindow */
  109.   void edit_preferences();
  110.   /** called by textWindow */
  111.   const TextOfMovieT *get_movie_text( int id );
  112.   /** test */
  113.   bool is_movie_text_loaded( int id );
  114.   /** called by search window */
  115.   const WordOccurencesT &find_word( const string &w ) const {
  116.     return wordDb->find_word( w );
  117.   }
  118.   void find_similar_words( const string &word, GList *similar ) const {
  119.     return wordDb->find_similar_words( word, similar );
  120.   }
  121.   void get_hint_words( const string &word, GList *&similar ) const {
  122.     return wordDb->find_hint_words( word, similar );
  123.   }
  124.   int  close_text_window( GdkEventAny *ev );
  125.   void menu_close_text_window( int id );
  126.   void notify_text_win_die( int movieId );
  127.   /** called by textWindow. Stop broadcast at the same time.
  128.       This call first load all data from the database server, then 
  129.       look at preference best1PushServID and select the best push server
  130.       that can play this movie. If no best server - select the random one
  131.    */
  132.   void playVideo( TextWindow &tw, struct tm t, int id );
  133.   /** Start broadcast, stop video playback. The channel number must be 
  134.       specified 
  135.   */
  136.   void playBroadcast( const string &url );
  137.   /** stop playback or broadcast video */
  138.   void stop();
  139.   /** tell database server that this movie should be recorded now */
  140.   void start_recording( int channel_id );
  141.   void stop_recording( int channel_id );
  142.   /** called by playback window */
  143.   void select_text_line_by_time( int movieId, time_t t );
  144.   /** called by broadcast window */
  145.   void fill_channellist( channel_infos_mapT &channel_infos_map );
  146.   ///@name callbacks
  147.   //@{
  148.   /** this is main destroy application callback. called from main window
  149.    */
  150.   void callback_destroy_session();
  151.   /** search text */
  152.   void callback_search();
  153.   void callback_superuser();
  154.   void callback_server_preferences();
  155.   void callback_broadcast();
  156.   //@}
  157.   void loadServerProperties( ServerConfigItemVec &props );
  158.   void saveServerProperties( ServerConfigItemVec &props );
  159.   void login_superuser( string passwd );
  160.   /** called by timeout */
  161.   gint timeout();
  162.   /** display string on debug window */
  163.   void put_message( int debl, const string &msg );
  164.   void put_message( int debl, const char *format, ... );
  165. };
  166. class GeneralException : public BasicException {
  167. public:
  168.   GeneralException( const char *format, ... );
  169. };
  170. #endif  //  _session_h_