Changeset 151

Show
Ignore:
Timestamp:
03/08/07 17:39:15 (2 years ago)
Author:
kbarnes3
Message:

Added the ability for the UI to add a server connection by zeroconf name.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dmp/trunk/Bridge/Bridge.cs

    r140 r151  
    106106                        } 
    107107                        catch { 
     108                                return -1; 
     109                        } 
     110                } 
     111 
     112                /// <summary> 
     113                /// Connects to the given server and eventually will get the songs from it 
     114                /// </summary> 
     115                /// <param name="zeroconfName">The Zeroconf name of the server to connect to</param> 
     116                /// <returns>The library id, which is referred to in the db and the  
     117                /// bridge's dictionary of clients or -1 if the connect fails</returns> 
     118                public int AddServerConnection(string zeroconfName) { 
     119                        Dictionary<string, Service> serverList = this.getZeroconfServerList(); 
     120                        if (serverList.ContainsKey(zeroconfName)) { 
     121                                Service theService = serverList[zeroconfName]; 
     122                                int result = this.AddServerConnection(theService); 
     123                                return result; 
     124                        } 
     125                        else { // The UI is smoking crack 
    108126                                return -1; 
    109127                        } 
     
    259277                                Console.WriteLine("Connected to " + newClient.Name); 
    260278 
     279 
     280                                if (this.serverNameToIdList != null) { 
     281                                        this.ServerAdded(this, new ServerStatusEventArgs(newClient.Name, true)); 
     282                                } 
     283 
    261284                                if (this.SongListChanged != null) { 
    262285                                        DataTable newSongs = this.getAvailableSongsInCollection(); 
     
    282305                        if (libraryId > -1) { //Reconnect to this server 
    283306                                int addResult = this.AddServerConnection(newServer); 
    284                                 if (addResult > -1) { 
    285                                         if (this.serverNameToIdList != null) { 
    286                                                 this.ServerAdded(this, new ServerStatusEventArgs(newServer.Name, true)); 
     307                                if (addResult <= -1) { //Connect failed 
     308                                        if (this.ServerAdded != null) { 
     309                                                this.ServerAdded(this, new ServerStatusEventArgs(newServer.Name, false)); 
    287310                                        } 
    288311                                }