示例#1
0
  public BrunetChatLogin(ChatConfigSerialization config)
  {
    _chat_config = config;
    
    string fname = "BrunetChat.glade";
    string root = "dialogBrunetChatLogin";
    Glade.XML gxml = new Glade.XML (fname, root, null);
    //Glade.XML gxml = new Glade.XML (null,fname, root, null);
    gxml.Autoconnect(this);

    int init_users = _chat_config.UserList.Users.Length;
    if (0 < init_users){
      userStrings = new ArrayList();
      userHashtable = new Hashtable();
      foreach(User user in _chat_config.UserList.Users ){
        userHashtable.Add(user.Email,user); 
        userStrings.Add(user.Email);
      }
      
      int count =  userStrings.Count;
      Console.WriteLine("User count: {0}",count);
      string[] popstring = new string[count];
      for (int loop = 0;loop<count;loop++){
        popstring[loop] = (string)userStrings[loop];
        Console.WriteLine(popstring[loop]);
      }
      comboEmail.PopdownStrings = popstring;
    }
    
  }
示例#2
0
 /** Main program. Logs in the user and creates the main window.
  */
 public static void Main (string[] args)
 {
   if (args.Length < 0){
     Console.WriteLine ("Usage:");
     return;
   }
   
   Threads.Init();
   Application.Init();
   
   ChatConfigSerialization chat_config = 
     new ChatConfigSerialization("Users.xml");
   
   chat_config.DeserializeUserList();  
   BrunetChatLogin dialog = new BrunetChatLogin(chat_config);
    
   dialog.dialogBrunetChatLogin.Run();
   
   if( false == dialog.userStrings.Contains(dialog.ComboEmail) )
   {
     chat_config.UserList.Prepend(new User("alias",dialog.ComboEmail,true) );
     chat_config.SerializeUserList();
   }
   
   BrunetChatMain app = new BrunetChatMain(dialog.CurrentUser(),chat_config);
   
   dialog.dialogBrunetChatLogin.Hide();
 
   Application.Run();
   app._store = null;
 }
示例#3
0
  /** Constructor. 
   * @param a_user The local user who will being chatting
   * @param chat_config Serializable meta-data 
   */
  public BrunetChatMain(User a_user, ChatConfigSerialization chat_config)
  {
    string fname = "BrunetChat.glade";
    string root = "windowBrunetChatMain";
    Glade.XML gxml = new Glade.XML (fname, root, null);
    //Glade.XML gxml = new Glade.XML (null,fname, root, null);
    gxml.Autoconnect(this);
    
    _current_user = a_user;
    //We make the node in the "chatrealm" so it won't interfere with
    //testing of any other Brunet nodes.
    _brunet_node = new StructuredNode(a_user.Address, "chatrealm");

    _chat_config = chat_config;
    _chat_config.BuddyListFilename = "Buddylist.xml";
    _chat_config.RemoteTAsFilename = "RemoteTransportAddresses.xml";
    _chat_config.LocalTcpPortFilename = "LocalTcpPort.xml";
    
    _chat_config.DeserializeLocalTcpPort();
    _brunet_node.AddEdgeListener( 
        new TcpEdgeListener(_chat_config.LocalTcpPort.TcpPort) );
    
    treeviewBuddies = (TreeView)gxml["treeviewBuddies"];
    _store = new ListStore(typeof(string),typeof(string),typeof(string));
    treeviewBuddies.Model = _store;

    //Here is the first column
    _buddy_col = new TreeViewColumn ();
    CellRenderer buddyrenderer = new CellRendererText ();
    _buddy_col.Title = "Buddy";
    _buddy_col.PackStart (buddyrenderer, true);
    _buddy_col.AddAttribute (buddyrenderer, "text", 0);
    treeviewBuddies.AppendColumn (_buddy_col);
    
    //Here is the second column
    _email_col = new TreeViewColumn ();
    CellRenderer emailrenderer = new CellRendererText ();
    _email_col.Title = "Email";
    _email_col.PackStart (emailrenderer, true);
    _email_col.AddAttribute (emailrenderer, "text", 1);
    treeviewBuddies.AppendColumn (_email_col);
    
    //Here is the third column
    _status_col = new TreeViewColumn ();
    CellRenderer statusrenderer = new CellRendererText ();
    _status_col.Title = "Status";
    _status_col.PackStart (statusrenderer, true);
    _status_col.AddAttribute (statusrenderer, "text", 2);
    treeviewBuddies.AppendColumn (_status_col);
   
    _message_sinks = new Hashtable();
    
    _chat_config.DeserializeBuddyList();
    this.Buddies.Node = _brunet_node;
    this.Buddies.User = CurrentUser;
    //Handle the chat events locally
    this.Buddies.ChatEvent += this.IncomingChatHandler;
    foreach (Buddy bud in Buddies){
      if( bud.Sender != null ) {
        bud.Node = _brunet_node;
        bud.User = CurrentUser;
        bud.StatusChanged += this.BuddyChangeHandler;
        _store.AppendValues(bud.Alias, bud.Email, bud.Status);
      }
    }
    
    _chat_config.DeserializeRemoteTAs();
    string[] tas = _chat_config.RemoteTAs.TAs;
    foreach (string ta in tas)
    {
      _brunet_node.RemoteTAs.Add(TransportAddressFactory.CreateInstance(ta) );
      //Console.WriteLine(ta);
    }
    _brunet_node.ConnectionTable.ConnectionEvent += this.OnConnectionChange;
    _brunet_node.ConnectionTable.DisconnectionEvent += this.OnConnectionChange;
    _brunet_node.Connect();
  }