Collaboration diagram for DCPlusPlus.HubList:
Public Member Functions | |
void | AbortFetch () |
Abort a fetch of a hublist. | |
delegate void | CompletedEventHandler (HubList hub_list) |
Prototype for the Completed Event Handler. | |
void | FetchHubs (string url) |
Start fetching a hublist [Non Blocking]. | |
void | FetchHubs () |
Start fetching a hublist needs url to point to a valid hublist to complete successfully [Non Blocking]. | |
HubList (string HubListUrl) | |
Hublist Constructor. | |
HubList () | |
Hublist Constructor. | |
delegate void | ProgressChangedEventHandler (HubList hub_list) |
Prototxype for teh Progress Changed Event Handler. | |
void | ReadXmlString (string xml) |
Read a hublist from a xml string [non blocking]. | |
[Test] void | TestHubListDownload () |
Test to see if a hublist download works as expected. | |
[Test] void | TestHubListDownloadFailWrongUrl () |
Test to see if a failed hublist download doesnt crash of throw uncatched exceptions. | |
delegate void | UnableToFetchEventHandler (HubList hub_list) |
Prototype for the Unable To Fetch Event Handler. | |
Public Attributes | |
event CompletedEventHandler | Completed |
Event handler that gets called when a hublist fetch was completed successfully. | |
event ProgressChangedEventHandler | ProgressChanged |
Event handler that gets called when the progress of a fetch changed. | |
event UnableToFetchEventHandler | UnableToFetch |
Event handler that gets called when a hublist fetch was unabble to complete. | |
Protected Attributes | |
string | address = "" |
bool | busy = false |
List< Column > | columns = new List<Column>() |
Connection.ErrorCodes | error_code = Connection.ErrorCodes.NoErrorYet |
List< Hub > | hubs = new List<Hub>() |
string | name = "" |
int | percentage = 0 |
string | url |
Properties | |
string | Address [get] |
get the address of the hublist ?? (why is there a field for this in a hublist?) | |
List< Column > | Columns [get] |
Get a list of columns in this hublist. | |
Connection.ErrorCodes | ErrorCode [get] |
Get the error code of the failed Fetch. | |
List< Hub > | Hubs [get] |
A list of hubs of this hublist. | |
bool | IsBusy [get] |
TRUE if a fetch is currently in progress. | |
string | Name [get] |
Get the name of the hublist. | |
int | Percentage [get] |
Get the actual progress percentage of the fetch. | |
string | Url [get, set] |
Get/Set the the url of the hublist. | |
Private Member Functions | |
void | DownloadFileCallback (object sender, DownloadDataCompletedEventArgs e) |
Async callback for webclients get file operation ,gets called if the file was retrieved successfully. | |
void | DownloadProgressCallback (object sender, DownloadProgressChangedEventArgs e) |
Async callback for webclients get file operation ,gets called when the progress of the download changes. | |
void | ProcessDownloadedBytes (byte[] input_bytes) |
Process the downloaded bytes from the webserver (uncompressing and reading of xml hublist) [non blocking]. | |
void | ProcessDownloadedBytesAsync (byte[] input_bytes) |
Process the downloaded bytes from the webserver (uncompressing and reading of xml hublist). | |
void | ProcessDownloadedBytesFinished (IAsyncResult result) |
Callback of Process Downloaded Bytes async operation. | |
delegate void | ProcessDownloadedBytesHandler (byte[] input_bytes) |
Private Prototype for the Process Downloaded Bytes Async Handler. | |
bool | ReadColumn (XmlNode node) |
Read values of a single column. | |
bool | ReadColumns (XmlNode node) |
Read Columns. | |
bool | ReadHub (XmlNode node) |
Read values of a single hub. | |
bool | ReadHubList (XmlNode node) |
Read hublist name and address and starts reading of the hubs tree. | |
bool | ReadHubs (XmlNode node) |
Read Hubs and starts reading of columns if present. | |
bool | ReadXmlStringAsync (string xml) |
Read a hublist from a xml string. | |
void | ReadXmlStringFinished (IAsyncResult result) |
Callback of ReadXmlString async operation. | |
delegate bool | ReadXmlStringHandler (string xml) |
Private Prototype for the Read Xml String Async Handler. | |
Private Attributes | |
WebClient | wc = new WebClient() |
our webclient instance that handles all the downloading work | |
Classes | |
class | Column |
a class describing one column of a hublist More... |
Definition at line 31 of file HubList.cs.
DCPlusPlus.HubList.HubList | ( | ) |
Hublist Constructor.
Definition at line 202 of file HubList.cs.
References DCPlusPlus.HubList.DownloadFileCallback(), DCPlusPlus.HubList.DownloadProgressCallback(), DCPlusPlus.HubList.Url, and DCPlusPlus.HubList.wc.
Referenced by DCPlusPlus.HubList.TestHubListDownload(), and DCPlusPlus.HubList.TestHubListDownloadFailWrongUrl().
00203 { 00204 Url = ""; 00205 wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressCallback); 00206 wc.DownloadDataCompleted += new DownloadDataCompletedEventHandler(DownloadFileCallback); 00207 }
Here is the call graph for this function:
Here is the caller graph for this function:
DCPlusPlus.HubList.HubList | ( | string | HubListUrl | ) |
Hublist Constructor.
HubListUrl | initialize the instance with an url of the hublist to be fetched |
Definition at line 212 of file HubList.cs.
References DCPlusPlus.HubList.DownloadFileCallback(), DCPlusPlus.HubList.DownloadProgressCallback(), DCPlusPlus.HubList.Url, and DCPlusPlus.HubList.wc.
00213 { 00214 Url = HubListUrl; 00215 wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressCallback); 00216 wc.DownloadDataCompleted += new DownloadDataCompletedEventHandler(DownloadFileCallback); 00217 }
Here is the call graph for this function:
void DCPlusPlus.HubList.AbortFetch | ( | ) |
Abort a fetch of a hublist.
Definition at line 260 of file HubList.cs.
References DCPlusPlus.HubList.busy, and DCPlusPlus.HubList.wc.
00261 { 00262 try 00263 { 00264 wc.CancelAsync(); 00265 } 00266 catch (Exception ex) 00267 { 00268 Console.WriteLine("Exception occured during abort: " + ex.Message); 00269 } 00270 00271 busy = false; 00272 00273 }
delegate void DCPlusPlus.HubList.CompletedEventHandler | ( | HubList | hub_list | ) |
Prototype for the Completed Event Handler.
hub_list | the hublist that completed a fetch |
void DCPlusPlus.HubList.DownloadFileCallback | ( | object | sender, | |
DownloadDataCompletedEventArgs | e | |||
) | [private] |
Async callback for webclients get file operation ,gets called if the file was retrieved successfully.
sender | event sending webclient instance | |
e | event arguments of the download operation |
Definition at line 280 of file HubList.cs.
References DCPlusPlus.HubList.busy, DCPlusPlus.HubList.error_code, DCPlusPlus.HubList.ProcessDownloadedBytes(), and DCPlusPlus.HubList.UnableToFetch.
Referenced by DCPlusPlus.HubList.HubList().
00281 { 00282 try 00283 { 00284 if (e.Cancelled) return; 00285 if (e.Result == null || e.Result.Length == 0) 00286 { 00287 error_code = Connection.ErrorCodes.UrlNotFound; 00288 Console.WriteLine("Error downloading hublist."); 00289 if (UnableToFetch != null) 00290 UnableToFetch(this); 00291 return; 00292 } 00293 //Console.WriteLine("Error:"+e.Error.Data.Values.ToString()); 00294 //if its a bz2 uncompress the data stream 00295 //Stream input = new StreamReader(e.Result); 00296 byte[] input_bytes = e.Result; 00297 ProcessDownloadedBytes(input_bytes); 00298 } 00299 catch (Exception ex) 00300 { 00301 error_code = Connection.ErrorCodes.Exception; 00302 Console.WriteLine("exception during hublist fetch: " + ex.Message); 00303 if (UnableToFetch != null) 00304 UnableToFetch(this); 00305 busy = false; 00306 } 00307 00308 }
Here is the call graph for this function:
Here is the caller graph for this function:
void DCPlusPlus.HubList.DownloadProgressCallback | ( | object | sender, | |
DownloadProgressChangedEventArgs | e | |||
) | [private] |
Async callback for webclients get file operation ,gets called when the progress of the download changes.
sender | event sending webclient instance | |
e | event arguments of the download operation |
Definition at line 423 of file HubList.cs.
References DCPlusPlus.HubList.percentage, and DCPlusPlus.HubList.ProgressChanged.
Referenced by DCPlusPlus.HubList.HubList().
00424 { 00425 percentage = e.ProgressPercentage;// TODO scale down to something like 70% if download has finished 00426 if (ProgressChanged != null) 00427 ProgressChanged(this); 00428 00429 }
Here is the caller graph for this function:
void DCPlusPlus.HubList.FetchHubs | ( | string | url | ) |
Start fetching a hublist [Non Blocking].
url | the url of the hublist |
Definition at line 252 of file HubList.cs.
References DCPlusPlus.HubList.FetchHubs().
Here is the call graph for this function:
void DCPlusPlus.HubList.FetchHubs | ( | ) |
Start fetching a hublist needs url to point to a valid hublist to complete successfully [Non Blocking].
Definition at line 223 of file HubList.cs.
References DCPlusPlus.HubList.busy, DCPlusPlus.HubList.columns, DCPlusPlus.HubList.error_code, DCPlusPlus.HubList.percentage, DCPlusPlus.HubList.ProgressChanged, DCPlusPlus.HubList.UnableToFetch, DCPlusPlus.HubList.url, and DCPlusPlus.HubList.wc.
Referenced by DCPlusPlus.HubList.FetchHubs(), DCPlusPlus.HubList.TestHubListDownload(), and DCPlusPlus.HubList.TestHubListDownloadFailWrongUrl().
00224 { 00225 if (!busy && !string.IsNullOrEmpty(url)) 00226 { 00227 busy = true; 00228 //hubs.Clear(); 00229 columns.Clear(); 00230 percentage = 0; 00231 if (ProgressChanged != null) 00232 ProgressChanged(this); 00233 try 00234 { 00235 wc.DownloadDataAsync(new Uri(url)); 00236 } 00237 catch (Exception ex) 00238 { 00239 Console.WriteLine("Exception occured during download: " + ex.Message); 00240 error_code = Connection.ErrorCodes.Exception; 00241 if (UnableToFetch != null) 00242 UnableToFetch(this); 00243 busy = false; 00244 } 00245 } 00246 }
Here is the caller graph for this function:
void DCPlusPlus.HubList.ProcessDownloadedBytes | ( | byte[] | input_bytes | ) | [private] |
Process the downloaded bytes from the webserver (uncompressing and reading of xml hublist) [non blocking].
input_bytes | array of bytes received from a webserver |
Definition at line 315 of file HubList.cs.
References DCPlusPlus.HubList.ProcessDownloadedBytesAsync(), DCPlusPlus.HubList.ProcessDownloadedBytesFinished(), and DCPlusPlus.HubList.ProcessDownloadedBytesHandler().
Referenced by DCPlusPlus.HubList.DownloadFileCallback().
00316 { 00317 ProcessDownloadedBytesHandler pdbh = new ProcessDownloadedBytesHandler(ProcessDownloadedBytesAsync); 00318 IAsyncResult result = pdbh.BeginInvoke(input_bytes, new AsyncCallback(ProcessDownloadedBytesFinished), pdbh); 00319 }
Here is the call graph for this function:
Here is the caller graph for this function:
void DCPlusPlus.HubList.ProcessDownloadedBytesAsync | ( | byte[] | input_bytes | ) | [private] |
Process the downloaded bytes from the webserver (uncompressing and reading of xml hublist).
input_bytes | array of bytes received from a webserver |
Definition at line 342 of file HubList.cs.
References DCPlusPlus.HubList.busy, DCPlusPlus.HubList.error_code, DCPlusPlus.HubList.ReadXmlStringAsync(), and DCPlusPlus.HubList.UnableToFetch.
Referenced by DCPlusPlus.HubList.ProcessDownloadedBytes().
00343 { 00344 MemoryStream input = new MemoryStream(input_bytes); 00345 MemoryStream output = new MemoryStream(); 00346 ASCIIEncoding ascii = new ASCIIEncoding(); 00347 UTF8Encoding utf = new UTF8Encoding(); 00348 UnicodeEncoding unicode = new UnicodeEncoding(); 00349 00350 try 00351 { 00352 ICSharpCode.SharpZipLib.BZip2.BZip2.Decompress(input, output); 00353 } 00354 catch (Exception ex) 00355 { 00356 error_code = Connection.ErrorCodes.Exception; 00357 Console.WriteLine("Error uncompressing hublist: " + ex.Message); 00358 if (UnableToFetch != null) 00359 UnableToFetch(this); 00360 busy = false; 00361 return; 00362 } 00363 input.Flush(); 00364 byte[] out_data = output.GetBuffer(); 00365 //string hubs_string = ascii.GetString(out_data); 00366 00367 string hubs_string = System.Text.Encoding.Default.GetString(out_data); 00368 //string hubs_string = utf.GetString(out_data); 00369 int end = hubs_string.IndexOf((char)0); 00370 if (end != -1) hubs_string = hubs_string.Remove(end); 00371 //string hubs_string = unicode.GetString(out_data); 00372 for (int i = 0; i < 0x1f; i++) 00373 if (i != 0x09 && i != 0x0a && i != 0x0d) hubs_string = hubs_string.Replace((char)i, ' ');//"�"+i+";" 00374 00375 hubs_string = hubs_string.Replace("&", "&"); 00376 bool inside_quotes = false; 00377 for (int i = 0; i < hubs_string.Length; i++) 00378 { 00379 if (hubs_string[i] == '\"' && inside_quotes == false) 00380 { 00381 inside_quotes = true; 00382 } 00383 else if (hubs_string[i] == '\"' && inside_quotes == true) 00384 { 00385 inside_quotes = false; 00386 } 00387 00388 if (inside_quotes && hubs_string[i] == '<') 00389 { 00390 hubs_string = hubs_string.Remove(i, 1); 00391 hubs_string = hubs_string.Insert(i, "<"); 00392 } 00393 00394 if (inside_quotes && hubs_string[i] == '>') 00395 { 00396 hubs_string = hubs_string.Remove(i, 1); 00397 hubs_string = hubs_string.Insert(i, ">"); 00398 } 00399 00400 if (inside_quotes && hubs_string[i] == '') 00401 { 00402 hubs_string = hubs_string.Remove(i, 1); 00403 hubs_string = hubs_string.Insert(i, " "); 00404 } 00405 00406 } 00407 //hubs_string = hubs_string.Replace("&", "&"); 00408 //Console.WriteLine(hubs_string); 00409 //File.WriteAllText("hublist.uncompressed.xml", hubs_string); 00410 //output.Position = 0; 00411 ReadXmlStringAsync(hubs_string); 00412 /*busy = false; 00413 if (Completed != null) 00414 Completed(this);*/ 00415 00416 }
Here is the call graph for this function:
Here is the caller graph for this function:
void DCPlusPlus.HubList.ProcessDownloadedBytesFinished | ( | IAsyncResult | result | ) | [private] |
Callback of Process Downloaded Bytes async operation.
result | Async Result/State |
Definition at line 329 of file HubList.cs.
References DCPlusPlus.HubList.busy, DCPlusPlus.HubList.Completed, and DCPlusPlus.HubList.ProcessDownloadedBytesHandler().
Referenced by DCPlusPlus.HubList.ProcessDownloadedBytes().
00330 { 00331 ProcessDownloadedBytesHandler pdbh = (ProcessDownloadedBytesHandler)result.AsyncState; 00332 pdbh.EndInvoke(result); 00333 busy = false; 00334 if (Completed != null) 00335 Completed(this); 00336 }
Here is the call graph for this function:
Here is the caller graph for this function:
delegate void DCPlusPlus.HubList.ProcessDownloadedBytesHandler | ( | byte[] | input_bytes | ) | [private] |
Private Prototype for the Process Downloaded Bytes Async Handler.
input_bytes | array of bytes received from a webserver |
Referenced by DCPlusPlus.HubList.ProcessDownloadedBytes(), and DCPlusPlus.HubList.ProcessDownloadedBytesFinished().
Here is the caller graph for this function:
delegate void DCPlusPlus.HubList.ProgressChangedEventHandler | ( | HubList | hub_list | ) |
Prototxype for teh Progress Changed Event Handler.
hub_list | the hublist which progress has changed |
bool DCPlusPlus.HubList.ReadColumn | ( | XmlNode | node | ) | [private] |
Read values of a single column.
node | xml node to read from |
Definition at line 631 of file HubList.cs.
References DCPlusPlus.HubList.columns, DCPlusPlus.HubList.Column.Name, and DCPlusPlus.HubList.Column.Type.
Referenced by DCPlusPlus.HubList.ReadColumns().
00632 { 00633 //Console.WriteLine("Reading Column information"); 00634 Column column = new Column(); 00635 foreach (XmlAttribute attr in node.Attributes) 00636 { 00637 //Console.WriteLine("attr:" + attr.Name + " - " + attr.Value); 00638 if (attr.Name.Equals("Name")) column.Name = attr.Value; 00639 if (attr.Name.Equals("Type")) column.Type = attr.Value; 00640 } 00641 columns.Add(column); 00642 return (true); 00643 }
Here is the caller graph for this function:
bool DCPlusPlus.HubList.ReadColumns | ( | XmlNode | node | ) | [private] |
Read Columns.
node | xml node to begin reading from |
Definition at line 613 of file HubList.cs.
References DCPlusPlus.HubList.ReadColumn().
Referenced by DCPlusPlus.HubList.ReadHubs().
00614 { 00615 //Console.WriteLine("Reading Columns Tree"); 00616 if (node.HasChildNodes) 00617 { 00618 foreach (XmlNode child in node.ChildNodes) 00619 { 00620 if (child.Name.Equals("Column")) ReadColumn(child); 00621 } 00622 } 00623 00624 return (true); 00625 }
Here is the call graph for this function:
Here is the caller graph for this function:
bool DCPlusPlus.HubList.ReadHub | ( | XmlNode | node | ) | [private] |
Read values of a single hub.
node | xml node to read from |
Definition at line 649 of file HubList.cs.
References DCPlusPlus.Hub.Address, DCPlusPlus.Hub.Country, DCPlusPlus.Hub.Description, DCPlusPlus.HubList.hubs, DCPlusPlus.Connection.IP, DCPlusPlus.Hub.MaxHubs, DCPlusPlus.Hub.MaxUsers, DCPlusPlus.Hub.MinShare, DCPlusPlus.Hub.MinSlots, DCPlusPlus.Hub.Name, DCPlusPlus.Connection.Port, DCPlusPlus.Hub.Shared, and DCPlusPlus.Hub.Users.
Referenced by DCPlusPlus.HubList.ReadHubs().
00650 { 00651 //Console.WriteLine("Reading Hub information"); 00652 Hub hub = new Hub(); 00653 foreach (XmlAttribute attr in node.Attributes) 00654 { 00655 try 00656 { 00657 //Console.WriteLine("attr:" + attr.Name + " - " + attr.Value); 00658 if (attr.Name.Equals("Name")) hub.Name = attr.Value; 00659 if (attr.Name.Equals("Address")) hub.Address = attr.Value; 00660 if (attr.Name.Equals("Description")) hub.Description = attr.Value; 00661 if (attr.Name.Equals("Country")) hub.Country = attr.Value; 00662 if (attr.Name.Equals("IP")) hub.IP = attr.Value; 00663 if (attr.Name.Equals("Users") && !string.IsNullOrEmpty(attr.Value)) hub.Users = long.Parse(attr.Value); 00664 if (attr.Name.Equals("Shared") && !string.IsNullOrEmpty(attr.Value)) hub.Shared = long.Parse(attr.Value); 00665 if (attr.Name.Equals("Minshare") && !string.IsNullOrEmpty(attr.Value)) hub.MinShare = long.Parse(attr.Value); 00666 if (attr.Name.Equals("Minslots") && !string.IsNullOrEmpty(attr.Value)) hub.MinSlots = int.Parse(attr.Value); 00667 if (attr.Name.Equals("Maxhubs") && !string.IsNullOrEmpty(attr.Value)) hub.MaxHubs = int.Parse(attr.Value); 00668 if (attr.Name.Equals("Maxusers") && !string.IsNullOrEmpty(attr.Value)) hub.MaxUsers = long.Parse(attr.Value); 00669 if (attr.Name.Equals("Port") && !string.IsNullOrEmpty(attr.Value)) hub.Port = int.Parse(attr.Value); 00670 } 00671 catch (Exception e) 00672 { 00673 Console.WriteLine("Exception reading Hub-Values: "+e.Message); 00674 return (false); 00675 } 00676 } 00677 bool unique = true; 00678 foreach (Hub search in hubs) 00679 { 00680 if (search.Address == hub.Address) 00681 { 00682 //Console.WriteLine("duplicate hub entry found: "+hub.Name); 00683 unique = false; 00684 } 00685 } 00686 if(unique) 00687 hubs.Add(hub); 00688 return (true); 00689 }
Here is the caller graph for this function:
bool DCPlusPlus.HubList.ReadHubList | ( | XmlNode | node | ) | [private] |
Read hublist name and address and starts reading of the hubs tree.
node | xml node to begin reading from |
Definition at line 568 of file HubList.cs.
References DCPlusPlus.HubList.address, DCPlusPlus.HubList.name, and DCPlusPlus.HubList.ReadHubs().
Referenced by DCPlusPlus.HubList.ReadXmlStringAsync().
00569 { 00570 foreach (XmlAttribute attr in node.Attributes) 00571 { 00572 //Console.WriteLine("attr:" + attr.Name + " - " + attr.Value); 00573 if (attr.Name.Equals("Name")) name = attr.Value; 00574 if (attr.Name.Equals("Address")) address = attr.Value; 00575 } 00576 00577 if (node.HasChildNodes) 00578 { 00579 foreach (XmlNode child in node.ChildNodes) 00580 { 00581 if (child.Name.Equals("Hubs")) ReadHubs(child); 00582 } 00583 } 00584 00585 return (true); 00586 }
Here is the call graph for this function:
Here is the caller graph for this function:
bool DCPlusPlus.HubList.ReadHubs | ( | XmlNode | node | ) | [private] |
Read Hubs and starts reading of columns if present.
node | xml node to begin reading from |
Definition at line 593 of file HubList.cs.
References DCPlusPlus.HubList.ReadColumns(), and DCPlusPlus.HubList.ReadHub().
Referenced by DCPlusPlus.HubList.ReadHubList().
00594 { 00595 //Console.WriteLine("Reading Hubs Tree"); 00596 if (node.HasChildNodes) 00597 { 00598 foreach (XmlNode child in node.ChildNodes) 00599 { 00600 if (child.Name.Equals("Hub")) ReadHub(child); 00601 if (child.Name.Equals("Columns")) ReadColumns(child); 00602 Thread.Sleep(1);//simple way to decrease cpu lag of this large loop but at cost of time 00603 } 00604 } 00605 00606 return (true); 00607 }
Here is the call graph for this function:
Here is the caller graph for this function:
void DCPlusPlus.HubList.ReadXmlString | ( | string | xml | ) |
Read a hublist from a xml string [non blocking].
xml | the xml representation of a hublist |
Definition at line 545 of file HubList.cs.
References DCPlusPlus.HubList.ReadXmlStringAsync(), DCPlusPlus.HubList.ReadXmlStringFinished(), and DCPlusPlus.HubList.ReadXmlStringHandler().
00546 { 00547 ReadXmlStringHandler rxsh = new ReadXmlStringHandler(ReadXmlStringAsync); 00548 IAsyncResult result = rxsh.BeginInvoke(xml, new AsyncCallback(ReadXmlStringFinished), rxsh); 00549 }
Here is the call graph for this function:
bool DCPlusPlus.HubList.ReadXmlStringAsync | ( | string | xml | ) | [private] |
Read a hublist from a xml string.
xml | the xml representation of a hublist |
Definition at line 439 of file HubList.cs.
References DCPlusPlus.HubList.busy, DCPlusPlus.HubList.error_code, DCPlusPlus.HubList.ReadHubList(), and DCPlusPlus.HubList.UnableToFetch.
Referenced by DCPlusPlus.HubList.ProcessDownloadedBytesAsync(), and DCPlusPlus.HubList.ReadXmlString().
00440 { 00441 XmlDocument doc = new XmlDocument(); 00442 bool try_again = false; 00443 try 00444 { 00445 //Console.WriteLine("Starting to parse xml data."); 00446 doc.LoadXml(xml); 00447 //Console.WriteLine("Finished parsing."); 00448 00449 } 00450 catch (XmlException xe) 00451 { 00452 00453 string error_message = "Unexpected end of file has occurred. The following elements are not closed: "; 00454 if (xe.Message.StartsWith(error_message)) 00455 { 00456 string tags = xe.Message.Substring(error_message.Length); 00457 int end = tags.IndexOf("."); 00458 if (end != -1) 00459 { 00460 tags = tags.Substring(0, end); 00461 int last = 0; 00462 int split = 0; 00463 while ((split = tags.IndexOf(",", split)) != -1) 00464 { 00465 string tag = tags.Substring(last, split); 00466 last = split + 1; 00467 split++; 00468 //int line = xe.LineNumber; 00469 tag = tag.Trim(); 00470 xml = xml + "</" + tag + ">\r\n"; 00471 } 00472 string last_tag = tags.Substring(last); 00473 last_tag = last_tag.Trim(); 00474 xml = xml + "</" + last_tag + ">\r\n"; 00475 00476 } 00477 try_again = true; 00478 } 00479 else 00480 { 00481 error_code = Connection.ErrorCodes.Exception; 00482 Console.WriteLine("xml exception:" + xe.Message); 00483 if (UnableToFetch != null) 00484 UnableToFetch(this); 00485 busy = false; 00486 return (false); 00487 } 00488 00489 } 00490 00491 if (try_again) 00492 { 00493 try 00494 { 00495 //Console.WriteLine("Starting to parse xml data for a second time."); 00496 doc.LoadXml(xml); 00497 //Console.WriteLine("Finished parsing."); 00498 00499 } 00500 catch (XmlException xe) 00501 { 00502 Console.WriteLine("xml exception:" + xe.Message); 00503 return (false); 00504 } 00505 00506 00507 } 00508 00509 //TODO change this to a non xpath workarround version 00510 try 00511 { 00512 XmlNodeList nodelist = doc.SelectNodes("/"); 00513 foreach (XmlNode node in nodelist) 00514 { 00515 if (node.HasChildNodes) 00516 { 00517 foreach (XmlNode child in node.ChildNodes) 00518 { 00519 if (child.Name.Equals("Hublist")) ReadHubList(child); 00520 } 00521 } 00522 00523 } 00524 00525 } 00526 catch (XmlException xmle) 00527 { 00528 error_code = Connection.ErrorCodes.Exception; 00529 Console.WriteLine(xmle.Message); 00530 if (UnableToFetch != null) 00531 UnableToFetch(this); 00532 busy = false; 00533 return (false); 00534 00535 } 00536 00537 return (true); 00538 }
Here is the call graph for this function:
Here is the caller graph for this function:
void DCPlusPlus.HubList.ReadXmlStringFinished | ( | IAsyncResult | result | ) | [private] |
Callback of ReadXmlString async operation.
result | Async Result/State |
Definition at line 554 of file HubList.cs.
References DCPlusPlus.HubList.busy, DCPlusPlus.HubList.Completed, and DCPlusPlus.HubList.ReadXmlStringHandler().
Referenced by DCPlusPlus.HubList.ReadXmlString().
00555 { 00556 ReadXmlStringHandler rxsh = (ReadXmlStringHandler)result.AsyncState; 00557 bool ret = rxsh.EndInvoke(result); 00558 busy = false; 00559 if (Completed != null) 00560 Completed(this); 00561 }
Here is the call graph for this function:
Here is the caller graph for this function:
delegate bool DCPlusPlus.HubList.ReadXmlStringHandler | ( | string | xml | ) | [private] |
Private Prototype for the Read Xml String Async Handler.
xml | the xml representation of a hublist |
Referenced by DCPlusPlus.HubList.ReadXmlString(), and DCPlusPlus.HubList.ReadXmlStringFinished().
Here is the caller graph for this function:
[Test] void DCPlusPlus.HubList.TestHubListDownload | ( | ) |
Test to see if a hublist download works as expected.
Definition at line 696 of file HubList.cs.
References DCPlusPlus.HubList.Completed, DCPlusPlus.HubList.FetchHubs(), DCPlusPlus.HubList.HubList(), and DCPlusPlus.HubList.Hubs.
00697 { 00698 Console.WriteLine("Test to download a hublist."); 00699 bool wait = true; 00700 HubList hublist = new HubList("http://www.hublist.co.uk/hublist.xml.bz2"); 00701 //HubList hublist = new HubList("http://www.hublist.org/PublicHubList.xml.bz2"); 00702 hublist.Completed += delegate(HubList hub_list) 00703 { 00704 Console.WriteLine(""); 00705 Console.WriteLine("Fetch Completed (Hubs found : " + hub_list.Hubs.Count + ")"); 00706 wait = false; 00707 }; 00708 hublist.FetchHubs(); 00709 //hublist.FetchHubs("http://www.hublist.org/PublicHubList.xml.bz2"); 00710 Console.WriteLine("Waiting for data"); 00711 DateTime start = DateTime.Now; 00712 while (wait) 00713 { 00714 if (DateTime.Now - start > new TimeSpan(0, 0, 30)) 00715 { 00716 Console.WriteLine(""); 00717 Console.WriteLine("Operation took too long"); 00718 wait = false; 00719 Assert.Fail("Operation took too long"); 00720 } 00721 Console.Write("."); 00722 Thread.Sleep(250); 00723 } 00724 Console.WriteLine("Hublist Download Test successful."); 00725 00726 }
Here is the call graph for this function:
[Test] void DCPlusPlus.HubList.TestHubListDownloadFailWrongUrl | ( | ) |
Test to see if a failed hublist download doesnt crash of throw uncatched exceptions.
Definition at line 732 of file HubList.cs.
References DCPlusPlus.HubList.Address, DCPlusPlus.HubList.Completed, DCPlusPlus.HubList.FetchHubs(), DCPlusPlus.HubList.HubList(), DCPlusPlus.HubList.Hubs, and DCPlusPlus.HubList.UnableToFetch.
00733 { 00734 Console.WriteLine("Test to download a hublist (wrong url)."); 00735 bool wait = true; 00736 HubList hublist = new HubList("http://ww.hublist.co.uk/hublist.xml.bz2"); 00737 //HubList hublist = new HubList("http://www.hublist.org/PublicHubList.xml.bz2"); 00738 hublist.Completed += delegate(HubList hub_list) 00739 { 00740 Console.WriteLine(""); 00741 Console.WriteLine("Fetch Completed (Hubs found : " + hub_list.Hubs.Count + ")"); 00742 Assert.Fail("Failed at failing ;-("); 00743 }; 00744 00745 hublist.UnableToFetch += delegate(HubList hub_list_unable) 00746 { 00747 Console.WriteLine(""); 00748 Console.WriteLine("Unable to fetch hublist: "+ hub_list_unable.Address); 00749 wait = false; 00750 }; 00751 hublist.FetchHubs(); 00752 //hublist.FetchHubs("http://www.hublist.org/PublicHubList.xml.bz2"); 00753 Console.WriteLine("Waiting for data"); 00754 DateTime start = DateTime.Now; 00755 while (wait) 00756 { 00757 if (DateTime.Now - start > new TimeSpan(0, 0, 30)) 00758 { 00759 Console.WriteLine(""); 00760 Console.WriteLine("Operation took too long"); 00761 wait = false; 00762 Assert.Fail("Operation took too long"); 00763 } 00764 Console.Write("."); 00765 Thread.Sleep(250); 00766 } 00767 Console.WriteLine("Failed Hublist Download Test successful."); 00768 00769 }
Here is the call graph for this function:
delegate void DCPlusPlus.HubList.UnableToFetchEventHandler | ( | HubList | hub_list | ) |
Prototype for the Unable To Fetch Event Handler.
hub_list | the hublist that was unable to fetch a request |
string DCPlusPlus.HubList.address = "" [protected] |
bool DCPlusPlus.HubList.busy = false [protected] |
Definition at line 98 of file HubList.cs.
Referenced by DCPlusPlus.HubList.AbortFetch(), DCPlusPlus.HubList.DownloadFileCallback(), DCPlusPlus.HubList.FetchHubs(), DCPlusPlus.HubList.ProcessDownloadedBytesAsync(), DCPlusPlus.HubList.ProcessDownloadedBytesFinished(), DCPlusPlus.HubList.ReadXmlStringAsync(), and DCPlusPlus.HubList.ReadXmlStringFinished().
List<Column> DCPlusPlus.HubList.columns = new List<Column>() [protected] |
Definition at line 168 of file HubList.cs.
Referenced by DCPlusPlus.HubList.FetchHubs(), and DCPlusPlus.HubList.ReadColumn().
event CompletedEventHandler DCPlusPlus.HubList.Completed |
Event handler that gets called when a hublist fetch was completed successfully.
Definition at line 184 of file HubList.cs.
Referenced by DCPlusPlus.HubList.ProcessDownloadedBytesFinished(), DCPlusPlus.HubList.ReadXmlStringFinished(), DCPlusPlus.HubList.TestHubListDownload(), and DCPlusPlus.HubList.TestHubListDownloadFailWrongUrl().
Connection.ErrorCodes DCPlusPlus.HubList.error_code = Connection.ErrorCodes.NoErrorYet [protected] |
Definition at line 48 of file HubList.cs.
Referenced by DCPlusPlus.HubList.DownloadFileCallback(), DCPlusPlus.HubList.FetchHubs(), DCPlusPlus.HubList.ProcessDownloadedBytesAsync(), and DCPlusPlus.HubList.ReadXmlStringAsync().
List<Hub> DCPlusPlus.HubList.hubs = new List<Hub>() [protected] |
string DCPlusPlus.HubList.name = "" [protected] |
int DCPlusPlus.HubList.percentage = 0 [protected] |
Definition at line 59 of file HubList.cs.
Referenced by DCPlusPlus.HubList.DownloadProgressCallback(), and DCPlusPlus.HubList.FetchHubs().
event ProgressChangedEventHandler DCPlusPlus.HubList.ProgressChanged |
Event handler that gets called when the progress of a fetch changed.
Definition at line 189 of file HubList.cs.
Referenced by DCPlusPlus.HubList.DownloadProgressCallback(), and DCPlusPlus.HubList.FetchHubs().
event UnableToFetchEventHandler DCPlusPlus.HubList.UnableToFetch |
Event handler that gets called when a hublist fetch was unabble to complete.
Definition at line 194 of file HubList.cs.
Referenced by DCPlusPlus.HubList.DownloadFileCallback(), DCPlusPlus.HubList.FetchHubs(), DCPlusPlus.HubList.ProcessDownloadedBytesAsync(), DCPlusPlus.HubList.ReadXmlStringAsync(), and DCPlusPlus.HubList.TestHubListDownloadFailWrongUrl().
string DCPlusPlus.HubList.url [protected] |
WebClient DCPlusPlus.HubList.wc = new WebClient() [private] |
our webclient instance that handles all the downloading work
Definition at line 198 of file HubList.cs.
Referenced by DCPlusPlus.HubList.AbortFetch(), DCPlusPlus.HubList.FetchHubs(), and DCPlusPlus.HubList.HubList().
string DCPlusPlus.HubList.Address [get] |
get the address of the hublist ?? (why is there a field for this in a hublist?)
Definition at line 125 of file HubList.cs.
Referenced by DCPlusPlus.HubList.TestHubListDownloadFailWrongUrl().
List<Column> DCPlusPlus.HubList.Columns [get] |
Connection.ErrorCodes DCPlusPlus.HubList.ErrorCode [get] |
List<Hub> DCPlusPlus.HubList.Hubs [get] |
A list of hubs of this hublist.
Definition at line 91 of file HubList.cs.
Referenced by DCPlusPlus.HubList.TestHubListDownload(), and DCPlusPlus.HubList.TestHubListDownloadFailWrongUrl().
bool DCPlusPlus.HubList.IsBusy [get] |
string DCPlusPlus.HubList.Name [get] |
int DCPlusPlus.HubList.Percentage [get] |
string DCPlusPlus.HubList.Url [get, set] |
Get/Set the the url of the hublist.
Definition at line 75 of file HubList.cs.
Referenced by DCPlusPlus.HubList.HubList().