Changeset 646
- Timestamp:
- 01/14/10 16:20:25 (2 months ago)
- Location:
- apps/outlook/branches/1.6
- Files:
-
- 11 modified
-
DotTel/dottel.pref (modified) (1 diff)
-
DotTel/inspector-results.xslt (modified) (10 diffs)
-
DotTel/MSOutlook/Toolbars/ContactToolbar/InspectorToolbar.cs (modified) (4 diffs)
-
DotTel/results.xslt (modified) (7 diffs)
-
DotTel/style.css (modified) (6 diffs)
-
DotTelSystem/DNS/Records/DNSTelnameNaptrResourceRecord.cs (modified) (8 diffs)
-
DotTelSystem/Friending/Messaging/Messaging.cs (modified) (2 diffs)
-
DotTelSystem/Lookup/LookupResult.cs (modified) (28 diffs)
-
DotTelSystem/Lookup/LookupTelname.cs (modified) (13 diffs)
-
DotTel/ThisAddIn.cs (modified) (1 diff)
-
Resolver.suo (modified) (previous)
Legend:
- Unmodified
- Added
- Removed
-
apps/outlook/branches/1.6/DotTel/dottel.pref
r338 r646 4 4 # Commenting these values out results in the system settings being used 5 5 6 #dns=208.67.222.2227 6 dnsport=53 8 7 timeout=3000 -
apps/outlook/branches/1.6/DotTel/inspector-results.xslt
r338 r646 12 12 <body> 13 13 <div id="results_title"> 14 <div id="results_dottel_name"> 15 <xsl:value-of select="TelnicLookupResults/Domain"/> 16 </div> 17 </div> 14 <div id="results_dottel_name"> 15 <xsl:choose> 16 <xsl:when test="/TelnicLookupResults/ddsValue"> 17 <xsl:value-of select="TelnicLookupResults/ddsValue"/> 18 </xsl:when> 19 <xsl:otherwise> 20 <xsl:value-of select="TelnicLookupResults/Domain"/> 21 </xsl:otherwise> 22 </xsl:choose> 23 </div> 24 </div> 25 18 26 19 27 <div id="results"> 20 28 21 29 <div id="results_container"> 22 30 23 31 <xsl:if test="/TelnicLookupResults/Crumbs"> 24 32 <div class="breadcrumbs"> … … 78 86 </div> 79 87 </xsl:if> 80 88 81 89 <xsl:if test="/TelnicLookupResults/Message"> 82 90 <div class="message"> … … 86 94 </xsl:otherwise> 87 95 </xsl:choose> 88 96 89 97 <xsl:for-each select="TelnicLookupResults/TxtResults/TxtRecord"> 90 98 <div class="textrecord txtrecord"> … … 132 140 </xsl:if> 133 141 </span> 142 <div class="longLabelslist"> 143 <xsl:for-each select="LongLabels/LongLabel"> 144 <span class="longLabel"> 145 <xsl:value-of select="LongLabelName" disable-output-escaping="yes"/> 146 </span> 147 </xsl:for-each> 148 </div> 149 150 151 134 152 <xsl:choose> 135 153 <xsl:when test="Launchable = 'true'"> … … 147 165 </xsl:choose> 148 166 </div> 149 </xsl:for-each>167 </xsl:for-each> 150 168 151 169 <xsl:for-each select="TelnicLookupResults/NaptrResults/NonTerminalNaptrRecord"> … … 155 173 </div> 156 174 <span class="serviceDescription"> 157 Go to: 175 <xsl:choose> 176 <xsl:when test="LongLabels"> 177 <xsl:for-each select="LongLabels/LongLabel"> 178 <xsl:value-of select="LongLabelName" disable-output-escaping="yes"/> 179 </xsl:for-each> 180 181 </xsl:when> 182 <xsl:otherwise> 183 Go to: 184 </xsl:otherwise> 185 </xsl:choose> 158 186 </span> 159 187 <div class="service_container"> … … 163 191 </div> 164 192 </div> 193 165 194 </xsl:for-each> 166 195 167 <xsl:for-each select="TelnicLookupResults/LocResults/LocRecord">168 <div class="locrecord">169 <div class="service_icon">170 <img src="{/TelnicLookupResults/Path}/images/icon-location.gif" />171 </div>172 <span class="serviceDescription">173 Location:174 </span>175 <div class="service_container">176 <a href="" onclick="window.external.launchLocation('{LocationWithEscapedQuotes}')">177 <xsl:value-of select="Latitude"/>178 ,179 <xsl:value-of select="Longitude"/>180 </a>181 </div>182 </div>183 </xsl:for-each>184 185 <xsl:if test="TelnicLookupResults/ TxtResults/EnhancedTxtRecord">196 <xsl:for-each select="TelnicLookupResults/LocResults/LocRecord"> 197 <div class="locrecord"> 198 <div class="service_icon"> 199 <img src="{/TelnicLookupResults/Path}/images/icon-location.gif" /> 200 </div> 201 <span class="serviceDescription"> 202 Location: 203 </span> 204 <div class="service_container"> 205 <a href="" onclick="window.external.launchLocation('{LocationWithEscapedQuotes}')"> 206 <xsl:value-of select="Latitude"/> 207 , 208 <xsl:value-of select="Longitude"/> 209 </a> 210 </div> 211 </div> 212 </xsl:for-each> 213 214 <xsl:if test="TelnicLookupResults/KeywordResults/EnhancedTxtRecord"> 186 215 <div class="keywords"> 187 216 <div class="service_icon"> … … 192 221 </span> 193 222 <div class="service_container"> 194 <xsl:for-each select="TelnicLookupResults/TxtResults/EnhancedTxtRecord"> 223 <xsl:for-each select="TelnicLookupResults/KeywordResults/EnhancedTxtRecord"> 224 <xsl:if test="Type='FreeText'"> 225 <div class="keywordline"> 226 <span class="keyword"> 227 <xsl:value-of select="PrimaryPair/Value" disable-output-escaping="yes"/> 228 </span> 229 </div> 230 </xsl:if> 231 </xsl:for-each> 232 <xsl:for-each select="TelnicLookupResults/KeywordResults/EnhancedTxtRecord"> 195 233 <xsl:choose> 196 <xsl:when test=" Count='1'">234 <xsl:when test="Type='Structured'"> 197 235 <div class="keywordline"> 198 236 <span class="primarykeyword"> 199 237 <xsl:choose> 200 238 <xsl:when test="PrimaryPair/Value"> 201 <xsl:value-of select="PrimaryPair/Value"/> 239 <xsl:value-of select="PrimaryPair/Key-name"/> 240 <xsl:text> - </xsl:text> 241 <xsl:value-of select="PrimaryPair/Value" disable-output-escaping="yes"/> 242 <xsl:text>: </xsl:text> 202 243 </xsl:when> 203 244 <xsl:otherwise> … … 206 247 </xsl:choose> 207 248 </span> 249 <xsl:for-each select="Pair"> 250 <span class="keyword"> 251 <div> 252 <xsl:value-of select="Value"/> 253 </div> 254 </span> 255 </xsl:for-each> 208 256 </div> 209 257 </xsl:when> 210 258 <xsl:otherwise> 211 < div class="keywordline">212 < span class="primarykeyword">259 <xsl:for-each select="Pair"> 260 <div class="keywordline"> 213 261 <xsl:choose> 214 <xsl:when test="PrimaryPair/Value"> 215 <xsl:value-of select="PrimaryPair/Value"/> 262 <xsl:when test="Value"> 263 <span class="primarykeyword"> 264 <xsl:value-of select="Key-name"/> 265 <xsl:text>: </xsl:text> 266 </span> 267 <span class="keyword"> 268 <xsl:value-of select="Value" disable-output-escaping="yes"/> 269 </span> 216 270 </xsl:when> 217 271 <xsl:otherwise> 218 <xsl:value-of select="PrimaryPair/Key-name"/> 272 <span class="primarykeyword"> 273 <xsl:value-of select="Key-name"/> 274 </span> 219 275 </xsl:otherwise> 220 276 </xsl:choose> 221 : 222 </span> 223 <xsl:for-each select="Pair"> 224 <span class="keyword"> 225 <xsl:value-of select="Value"/> 226 </span> 227 </xsl:for-each> 228 </div> 277 </div> 278 </xsl:for-each> 229 279 </xsl:otherwise> 230 280 </xsl:choose> 281 282 231 283 </xsl:for-each> 232 284 </div> … … 235 287 236 288 </div> 237 238 <xsl:if test="/TelnicLookupResults/PreviousDomain"> 239 <div class="contact"> 240 <div class="service_icon"> 241 <img src="{/TelnicLookupResults/Path}/images/icon-back.gif"/> 289 290 291 <xsl:if test="/TelnicLookupResults/PreviousDomain"> 292 <div class="contact"> 293 <div class="service_icon"> 294 <img src="{/TelnicLookupResults/Path}/images/icon-back.gif"/> 295 </div> 296 <div class="service_container"> 297 <a href="" onclick="window.external.goBack()">Go Back</a> 298 </div> 299 </div> 300 </xsl:if> 301 302 <div class="buttons"> 303 <xsl:if test="TelnicLookupResults/NaptrResults/TerminalNaptrRecord"> 304 <button onclick="window.external.displayImportScreen();">Save Results</button> 305 </xsl:if> 306 <button onclick="window.external.closeWindow();">Close</button> 242 307 </div> 243 <div class="service_container"> 244 <a href="" onclick="window.external.goBack()">Go Back</a> 245 </div> 308 246 309 </div> 247 </xsl:if>248 249 <div class="buttons">250 <xsl:if test="TelnicLookupResults/NaptrResults/TerminalNaptrRecord">251 <button onclick="window.external.displayImportScreen();">Save Results</button>252 </xsl:if>253 <button onclick="window.external.closeWindow();">Close</button>254 </div>255 256 </div>257 310 <div id="footerwok"></div> 258 311 -
apps/outlook/branches/1.6/DotTel/MSOutlook/Toolbars/ContactToolbar/InspectorToolbar.cs
r493 r646 285 285 286 286 this.SetFriendingComponents(); 287 287 Logger.Log(Logger.Section.Contact_Toolbar, "Before AutoLookupThread"); 288 288 // perform a lookup 289 289 Thread t = new Thread(delegate() 290 290 { 291 Logger.Log(Logger.Section.Contact_Toolbar, "Start of AutoLookupThread"); 291 292 this.AutoLookup(); 293 Logger.Log(Logger.Section.Contact_Toolbar, "End of AutoLookupThread"); 292 294 }); 293 295 t.Name = "AutoLookup Thread"; 294 296 t.Start(); 297 Logger.Log(Logger.Section.Contact_Toolbar, "After Launching AutoLookup Thread"); 295 298 296 299 Publishers.Instance.publishersListUpdated += new Publishers.PublishersListUpdatedHandler(publishersListUpdated); … … 447 450 && (editButton.Caption == DotTel.Properties.Resources.InspectorToolbar_EditButtonCaption)) 448 451 { 449 if (Publishers.Instance.PublisherList.ContainsKey(telname)) 452 //if (Publishers.Instance.PublisherList.ContainsKey(telname)) 453 if (Publishers.Instance.GetPrivateTelname(telname) != telname) 450 454 { 451 455 // enable the friend button only if this domain is in the publishers list … … 639 643 LookupTelname lt = new LookupTelname(IPAddress.Parse(Preferences.GetPreference("dns")), int.Parse(Preferences.GetPreference("dnsport"))); 640 644 lt.Listener = this; 641 string privateTelname = telname; 642 // if this telname is in the publishers list then use the subdomain 643 if (Publishers.Instance.PublisherList != null && Publishers.Instance.PublisherList.ContainsKey(telname)) 644 { 645 privateTelname = Publishers.Instance.PublisherList[telname]; 646 if (!privateTelname.EndsWith(".tel")) 647 { 648 privateTelname += "." + telname; 649 } 650 } 651 645 string privateTelname = Publishers.Instance.GetPrivateTelname(telname); 652 646 if (inspectorGoButton == null) 653 647 return; … … 802 796 catch(Exception e) 803 797 { 804 Logger.Log(Logger.Section.Contact_Toolbar, "saveTelname exception: " + e.StackTrace);798 Logger.Log(Logger.Section.Contact_Toolbar, "saveTelname exception: " + this.GetTelname() + " - "+ e.StackTrace); 805 799 MessageBox.Show(DotTel.Properties.Resources.InspectorToolbar_InvalidDotTelDomain, 806 800 DotTel.Properties.Resources.DottelError, MessageBoxButtons.OK, MessageBoxIcon.Error); -
apps/outlook/branches/1.6/DotTel/results.xslt
r338 r646 12 12 <body> 13 13 <div id="results_title"> 14 <div id="results_dottel_name"> 14 <div id="results_dottel_name"> 15 <xsl:choose> 16 <xsl:when test="/TelnicLookupResults/ddsValue"> 17 <xsl:value-of select="TelnicLookupResults/ddsValue" /> 18 </xsl:when> 19 <xsl:otherwise> 15 20 <xsl:value-of select="TelnicLookupResults/Domain"/> 16 </div> 17 </div> 18 19 <div id="results"> 21 </xsl:otherwise> 22 </xsl:choose> 23 </div> 24 </div> 25 26 <div id="results"> 20 27 21 28 <div id="results_container"> … … 106 113 </xsl:if> 107 114 </div> 108 <span class="serviceDescription"> 109 <xsl:if test="LocationIndicatorHints/ConcatenatedCategories=' '"> 110 <xsl:value-of select="ServiceName"/> 115 <div class="inner"> 116 <span class="serviceDescription"> 117 <xsl:if test="LocationIndicatorHints/ConcatenatedCategories=' '"> 118 <xsl:value-of select="ServiceName"/> 119 </xsl:if> 120 <xsl:if test="LocationIndicatorHints/ConcatenatedCategories != ' '"> 121 <xsl:value-of select="LocationIndicatorHints/ConcatenatedCategories"/> 122 <xsl:text> </xsl:text> 123 <xsl:value-of select="ServiceName"/> 124 </xsl:if> 125 <span class="xlabelslist"> 126 <xsl:if test="XLabels/Count>0"> 127 <xsl:text>(</xsl:text> 128 </xsl:if> 129 <xsl:for-each select="XLabels/XLabel"> 130 <span class="xlabel"> 131 <xsl:value-of select="XLabelName" disable-output-escaping="yes"/> 132 </span> 133 </xsl:for-each> 134 <xsl:if test="XLabels/Count>0"> 135 <xsl:text>)</xsl:text> 136 </xsl:if> 137 </span> 138 </span> 139 140 141 142 <xsl:if test="LongLabels"> 143 <div class="longLabelslist"> 144 <xsl:for-each select="LongLabels/LongLabel"> 145 <span class="longLabel"> 146 <xsl:value-of select="LongLabelName" disable-output-escaping="yes"/> 147 </span> 148 </xsl:for-each> 149 </div> 111 150 </xsl:if> 112 <xsl:if test="LocationIndicatorHints/ConcatenatedCategories != ' '"> 113 <xsl:value-of select="LocationIndicatorHints/ConcatenatedCategories"/> 114 <xsl:text> </xsl:text> 115 <xsl:value-of select="ServiceName"/> 116 </xsl:if> 117 </span> 118 <span class="xlabelslist"> 119 <xsl:if test="XLabels/Count>0"> 120 <xsl:text>(</xsl:text> 121 </xsl:if> 122 <xsl:for-each select="XLabels/XLabel"> 123 <span class="xlabel"> 124 <xsl:value-of select="XLabelName"/> 125 </span> 126 </xsl:for-each> 127 <xsl:if test="XLabels/Count>0"> 128 <xsl:text>)</xsl:text> 129 </xsl:if> 130 </span> 131 <xsl:choose> 132 <xsl:when test="Launchable = 'true'"> 133 <div class="service_container"> 134 <a href="" onclick="window.external.launch('{ServiceType}', '{Uri}')"> 151 152 153 154 <xsl:choose> 155 <xsl:when test="Launchable = 'true'"> 156 <div class="service_container"> 157 <a href="" onclick="window.external.launch('{ServiceType}', '{Uri}')"> 158 <xsl:value-of select="Name"/> 159 </a> 160 </div> 161 </xsl:when> 162 <xsl:otherwise> 163 <div class="service_container"> 135 164 <xsl:value-of select="Name"/> 136 </a> 137 </div> 138 </xsl:when> 139 <xsl:otherwise> 140 <div class="service_container"> 141 <xsl:value-of select="Name"/> 142 </div> 143 </xsl:otherwise> 144 </xsl:choose> 165 </div> 166 </xsl:otherwise> 167 </xsl:choose> 168 169 170 171 </div> 145 172 </div> 146 173 </xsl:for-each> … … 152 179 </div> 153 180 <span class="serviceDescription"> 154 Go to: 181 <xsl:choose> 182 <xsl:when test="LongLabels"> 183 <xsl:for-each select="LongLabels/LongLabel"> 184 <xsl:value-of select="LongLabelName" disable-output-escaping="yes"/> 185 </xsl:for-each> 186 187 </xsl:when> 188 <xsl:otherwise> 189 Go to: 190 </xsl:otherwise> 191 </xsl:choose> 155 192 </span> 156 193 <div class="service_container"> … … 160 197 </div> 161 198 </div> 199 162 200 </xsl:for-each> 163 201 … … 180 218 </xsl:for-each> 181 219 182 <xsl:if test="TelnicLookupResults/ TxtResults/EnhancedTxtRecord">220 <xsl:if test="TelnicLookupResults/KeywordResults/EnhancedTxtRecord"> 183 221 <div class="keywords"> 184 222 <div class="service_icon"> … … 189 227 </span> 190 228 <div class="service_container"> 191 <xsl:for-each select="TelnicLookupResults/TxtResults/EnhancedTxtRecord"> 192 <xsl:choose> 193 <xsl:when test="Count='1'"> 229 <xsl:for-each select="TelnicLookupResults/KeywordResults/EnhancedTxtRecord"> 230 <xsl:if test="Type='FreeText'"> 194 231 <div class="keywordline"> 232 <span class="keyword"> 233 <xsl:value-of select="PrimaryPair/Value" disable-output-escaping="yes"/> 234 </span> 235 </div> 236 </xsl:if> 237 </xsl:for-each> 238 <xsl:for-each select="TelnicLookupResults/KeywordResults/EnhancedTxtRecord"> 239 <xsl:choose> 240 <xsl:when test="Type='Structured'"> 241 <div class="keywordline"> 195 242 <span class="primarykeyword"> 196 243 <xsl:choose> 197 244 <xsl:when test="PrimaryPair/Value"> 198 <xsl:value-of select="PrimaryPair/Value"/> 245 <xsl:value-of select="PrimaryPair/Key-name"/> 246 <xsl:text> - </xsl:text> 247 <xsl:value-of select="PrimaryPair/Value" disable-output-escaping="yes"/> 248 <xsl:text>: </xsl:text> 199 249 </xsl:when> 200 250 <xsl:otherwise> … … 203 253 </xsl:choose> 204 254 </span> 205 </div> 206 </xsl:when> 207 <xsl:otherwise> 208 <div class="keywordline"> 209 <span class="primarykeyword"> 255 <xsl:for-each select="Pair"> 256 <span class="keyword"> 257 <div> 258 <xsl:value-of select="Value"/> 259 </div> 260 </span> 261 </xsl:for-each> 262 </div> 263 </xsl:when> 264 <xsl:otherwise> 265 <xsl:for-each select="Pair"> 266 <div class="keywordline"> 210 267 <xsl:choose> 211 <xsl:when test="PrimaryPair/Value"> 212 <xsl:value-of select="PrimaryPair/Value"/> 268 <xsl:when test="Value"> 269 <span class="primarykeyword"> 270 <xsl:value-of select="Key-name"/> 271 <xsl:text>: </xsl:text> 272 </span> 273 <span class="keyword"> 274 <xsl:value-of select="Value" disable-output-escaping="yes"/> 275 </span> 213 276 </xsl:when> 214 277 <xsl:otherwise> 215 <xsl:value-of select="PrimaryPair/Key-name"/> 278 <span class="primarykeyword"> 279 <xsl:value-of select="Key-name"/> 280 </span> 216 281 </xsl:otherwise> 217 282 </xsl:choose> 218 : 219 </span> 220 <xsl:for-each select="Pair"> 221 <span class="keyword"> 222 <xsl:value-of select="Value"/> 223 </span> 283 </div> 224 284 </xsl:for-each> 225 </div> 226 </xsl:otherwise> 227 </xsl:choose> 285 </xsl:otherwise> 286 </xsl:choose> 287 288 228 289 </xsl:for-each> 229 290 </div> -
apps/outlook/branches/1.6/DotTel/style.css
r338 r646 19 19 .keyword 20 20 { 21 padding-right: 10px; 22 vertical-align: middle; 21 /*padding-right: 10px;*/ 22 vertical-align: middle; 23 font-weight: normal; 23 24 } 24 25 button … … 41 42 font-weight:bold; 42 43 vertical-align: middle; 43 44 display:block; 45 margin-left: 48px; 44 46 } 45 47 … … 62 64 margin-left: 3px; 63 65 font-size:0.875em; 66 } 67 68 div.longlabelslist 69 { 70 width: 360px; 71 /*padding-left: 10px;*/ 72 color: Gray; 73 vertical-align: middle; 74 display:inline-block; 75 margin-left:56px; 76 } 77 78 div.inner 79 { 80 display:block; 81 } 82 83 span.longlabel 84 { 85 color: Gray; 86 /*float: right;*/ 87 margin: 0; 88 /*display:block;*/ 89 font-size:0.875em; 90 word-wrap: break-word; 64 91 } 65 92 … … 195 222 height: 45px; 196 223 vertical-align: top; 197 overflow: hidden;224 overflow:auto; 198 225 } 199 226 … … 225 252 { 226 253 vertical-align: middle; 254 margin-bottom:10px; 227 255 } 228 256 … … 250 278 /*css3 property to ensure the text is wrapped*/ 251 279 word-wrap: break-word; 280 margin-left:48px; 252 281 } 253 282 -
apps/outlook/branches/1.6/DotTelSystem/DNS/Records/DNSTelnameNaptrResourceRecord.cs
r493 r646 57 57 /// 58 58 [Serializable] 59 sealedpublic class DNSTelnameNaptrResourceRecord : DNSNaptrResourceRecord59 public class DNSTelnameNaptrResourceRecord : DNSNaptrResourceRecord 60 60 { 61 protected bool display; 62 public bool Display 63 { 64 get 65 { 66 return display; 67 } 68 69 } 70 61 71 /// <summary> return full URI from regexp string e.g. "tel:+441794833353" 62 72 /// … … 184 194 } 185 195 196 Logger.Log(Logger.Section.Lookups, "ntnTelname: " + ntnTelname); 197 Logger.Log(Logger.Section.Lookups, "ntnQuery: " + ntnQuery); 198 186 199 // remove the part of ntnTelname that is common with the query including 187 200 // the dot before the query suffix in the Telname, so … … 189 202 // then remove the .tel suffix if still present 190 203 int p = ntnTelname.ToLower().IndexOf(ntnQuery); 191 if (p != -1)204 if (p > 0) 192 205 { 193 206 ntnTelname = ntnTelname.Substring(0, (p - 1) - (0)); // -1 to remove dot … … 199 212 } 200 213 214 //Replace punycode with unicode 215 ntnTelname = Gnu.Inet.Encoding.IDNA.ToUnicode(ntnTelname); 201 216 // replace '-' with ' ' and '.' with '>' 202 217 ntnTelname = ntnTelname.Replace('-', ' '); … … 207 222 208 223 } 224 /// <summary> 225 /// The longlabels from the NAPTR 226 /// </summary> 227 public List<string> LongLabels 228 { 229 get 230 { 231 return longlabels; 232 } 233 set 234 { 235 this.longlabels = value; 236 } 237 } 238 209 239 210 240 /// <summary> … … 219 249 } 220 250 221 private List<string> labels; 251 protected List<string> labels; 252 253 protected List<string> longlabels; 222 254 223 255 /// <summary> query.</summary> 224 pr ivatestring query;256 protected string query; 225 257 226 258 /// <summary> uriPath.</summary> 227 pr ivatestring uriPath;259 protected string uriPath; 228 260 229 261 /// <summary> uriScheme.</summary> 230 pr ivatestring uriScheme; // includes trailing colon262 protected string uriScheme; // includes trailing colon 231 263 232 264 /// <summary> serviceType.</summary> 233 pr ivatestring serviceType;265 protected string serviceType; 234 266 /// <summary> catagory.</summary> 235 pr ivateList<string> catagories;267 protected List<string> catagories; 236 268 237 269 public static string GetLocationIndicatorHintPresentedText(string catagory) … … 272 304 /// <param name="naptr">the naptr 273 305 /// </param> 274 pr ivateDNSTelnameNaptrResourceRecord(DNSNaptrResourceRecord naptr)306 protected DNSTelnameNaptrResourceRecord(DNSNaptrResourceRecord naptr) 275 307 : base(naptr.TTL, naptr.order, naptr.preference, naptr.flagsStr, naptr.serviceStr, naptr.regexpStr, naptr.replaceStr, naptr.WasEncrypted) 276 308 { 309 longlabels = new List<string>(); 277 310 } 278 311 … … 397 430 throw new DNSTelnameNaptrInvalidException("colon missing in URI (\"" + uri + "\")"); 398 431 } 399 432 Logger.Log(Logger.Section.Lookups, "ntn uri:: " + uri); 433 400 434 string theUriScheme = uri.Substring(0, (colonPos + 1) - (0)); // scheme with ':' 401 435 string schemeName = uri.Substring(0, (colonPos) - (0)); // scheme without ':' -
apps/outlook/branches/1.6/DotTelSystem/Friending/Messaging/Messaging.cs
r338 r646 210 210 /// </summary> 211 211 /// <param name="telname">The domain to send the friend request to</param> 212 public void AddFriend(string telname) 213 { 212 public void AddFriend(string longtelname) 213 { 214 string telname = getShortTelname(longtelname); 214 215 Logger.Log(Logger.Section.Friending, "Befriending: " + telname); 215 216 Messaging.friendADDER.ComposeFriendingMessage(telname); … … 240 241 Logger.Log(Logger.Section.Contact_Toolbar, "Problem adding friend: " + e.Message); 241 242 } 243 } 244 245 /// <summary> 246 /// returns only the top level domain for friending 247 /// </summary> 248 /// <param name="longtelname"></param> 249 /// <returns></returns> 250 private string getShortTelname(string longtelname) 251 { 252 string[] split = longtelname.Split(new char[] { '.' }); 253 if (split.Length > 1) 254 return split[split.Length - 2] + "." + split[split.Length - 1]; 255 else 256 return longtelname; 242 257 } 243 258 -
apps/outlook/branches/1.6/DotTelSystem/Lookup/LookupResult.cs
r338 r646 115 115 } 116 116 117 /// <summary> The version records.</summary> 118 private System.Collections.ArrayList versionRecords; 119 /// <summary> The status of the txt lookup.</summary> 120 private LookupWorker.LookupStatus versionStatus; 121 122 public LookupWorker.LookupStatus VersionStatus 123 { 124 set 125 { 126 versionStatus = value; 127 } 128 get 129 { 130 return versionStatus; 131 } 132 } 133 117 134 /// <summary> The txt records.</summary> 118 135 private System.Collections.ArrayList nInfoRecords; … … 132 149 } 133 150 151 /// <summary> The keyword records.</summary> 152 private System.Collections.ArrayList keywordRecords; 153 /// <summary> The status of the keyword lookup.</summary> 154 private LookupWorker.LookupStatus keywordStatus; 155 156 public LookupWorker.LookupStatus KeywordStatus 157 { 158 set 159 { 160 keywordStatus = value; 161 } 162 get 163 { 164 return keywordStatus; 165 } 166 } 167 168 /// <summary> The long label records.</summary> 169 private System.Collections.ArrayList longLabelRecords; 170 171 134 172 /// <summary> 135 173 /// Check for equality based on matching resource records … … 144 182 // return false if we got a successful lookup 145 183 if (naptrStatus == LookupWorker.LookupStatus.Ok && txtStatus == LookupWorker.LookupStatus.Ok 146 && locStatus == LookupWorker.LookupStatus.Ok && nInfoStatus == LookupWorker.LookupStatus.Ok) 184 && locStatus == LookupWorker.LookupStatus.Ok && nInfoStatus == LookupWorker.LookupStatus.Ok 185 && keywordStatus == LookupWorker.LookupStatus.Ok && versionStatus == LookupWorker.LookupStatus.Ok) 147 186 { 148 187 return false; … … 156 195 // check if we've got the same telname 157 196 if (telname != lr.telname) return false; 197 198 // check if we've got the same dds 199 if (ddsValue != lr.ddsValue) return false; 200 201 // check if we've got the pddxVersion 202 if (pddxVersion != lr.pddxVersion) return false; 158 203 159 204 // if neither of us have any records then we must be the same (empty) … … 167 212 if (locRecords.Count != lr.LocRecords.Count) return false; 168 213 if (nInfoRecords.Count != lr.NInfoRecords.Count) return false; 214 if (keywordRecords.Count != lr.KeywordRecords.Count) return false; 215 if (longLabelRecords.Count != lr.longLabelRecords.Count) return false; 216 if (versionRecords.Count != lr.versionRecords.Count) return false; 169 217 } 170 218 catch (Exception) … … 206 254 } 207 255 if (!this.CompareLocRecordLists(lr.locRecords, locRecords)) 256 { 257 return false; 258 } 259 260 if (!this.CompareKeywordRecordLists(keywordRecords, lr.keywordRecords)) 261 { 262 return false; 263 } 264 if (!this.CompareKeywordRecordLists(lr.keywordRecords, keywordRecords)) 265 { 266 return false; 267 } 268 269 if (!this.CompareLongLabelRecordLists(longLabelRecords, lr.longLabelRecords)) 270 { 271 return false; 272 } 273 if (!this.CompareLongLabelRecordLists(lr.longLabelRecords, longLabelRecords)) 274 { 275 return false; 276 } 277 278 if (!this.CompareTxtRecordLists(versionRecords, lr.versionRecords)) 279 { 280 return false; 281 } 282 if (!this.CompareTxtRecordLists(lr.versionRecords, versionRecords)) 208 283 { 209 284 return false; … … 291 366 } 292 367 368 private bool CompareKeywordRecordLists(ArrayList first, ArrayList second) 369 { 370 if (first.Count == second.Count) 371 { 372 foreach (DNSTxtResourceRecord r1 in first) 373 { 374 bool found = false; 375 foreach (DNSTxtResourceRecord r2 in second) 376 { 377 if (r1.Equals(r2)) 378 { 379 found = true; 380 } 381 } 382 if (!found) 383 { 384 return false; 385 } 386 } 387 return true; 388 } 389 return false; 390 } 391 392 private bool CompareLongLabelRecordLists(ArrayList first, ArrayList second) 393 { 394 if (first.Count == second.Count) 395 { 396 foreach (DNSTxtResourceRecord r1 in first) 397 { 398 bool found = false; 399 foreach (DNSTxtResourceRecord r2 in second) 400 { 401 if (r1.Equals(r2)) 402 { 403 found = true; 404 } 405 } 406 if (!found) 407 { 408 return false; 409 } 410 } 411 return true; 412 } 413 return false; 414 } 415 293 416 private bool CompareLocRecordLists(ArrayList first, ArrayList second) 294 417 { … … 324 447 if (locRecords != null && locRecords.Count > 0) return true; 325 448 if (nInfoRecords != null && nInfoRecords.Count > 0) return true; 449 if (keywordRecords != null && keywordRecords.Count > 0) return true; 450 if (longLabelRecords != null && longLabelRecords.Count > 0) return true; 451 //Version Records deliberately not included 326 452 327 453 return false; … … 358 484 { 359 485 // none of the results should be null, so if they are set ttl to 0 360 if (txtRecords == null && naptrRecords == null && locRecords == null && nInfoRecords == null )486 if (txtRecords == null && naptrRecords == null && locRecords == null && nInfoRecords == null && keywordRecords == null && versionRecords == null) 361 487 { 362 488 ttl = 0; 363 489 } // if we don't have any actual results we can't work out a ttl, so set to 0 364 else if (txtRecords.Count == 0 && naptrRecords.Count == 0 && locRecords.Count == 0 && nInfoRecords.Count == 0 )490 else if (txtRecords.Count == 0 && naptrRecords.Count == 0 && locRecords.Count == 0 && nInfoRecords.Count == 0 && keywordRecords.Count == 0 && versionRecords.Count == 0) 365 491 { 366 492 ttl = 0; … … 374 500 /// <returns> the naptr records 375 501 /// </returns> 376 /// <summary> Sets the naptr records. 502 /// <summary> Sets the naptr records. If there are any long labels matching a naptr it updates it's long label field 377 503 /// 378 504 /// </summary> … … 397 523 updated = (System.DateTime.Now.Ticks - 621355968000000000) / 10000 / 1000; 398 524 setMinTtl(this.naptrRecords); 525 if (!(this.longLabelRecords == null)) 526 { 527 foreach (DNSTelnameNaptrResourceRecord naptr in this.naptrRecords) 528 { 529 foreach (DNSLongLabelTxtResourceRecord label in this.longLabelRecords) 530 { 531 if ((naptr.Order == label.Order) && (naptr.Preference == label.Priority)) 532 { 533 Logger.Log(Logger.Section.Lookups, "Long label matched " + label.TxtStr); 534 naptr.LongLabels = label.LongLabels; 535 } 536 } 537 } 538 } 399 539 } 400 540 } … … 417 557 { 418 558 this.locRecords = value; 419 //naptrRecords.Sort();420 559 updated = (System.DateTime.Now.Ticks - 621355968000000000) / 10000 / 1000; 421 560 setMinTtl(this.locRecords); … … 439 578 { 440 579 this.nInfoRecords = value; 580 this.updated = (System.DateTime.Now.Ticks - 621355968000000000) / 10000 / 1000; 581 this.setMinTtl(this.nInfoRecords); 582 } 583 } 584 } 585 586 /// <summary> 587 /// Checks for existing Naptrs and tries to match them to update their longLabel field 588 /// </summary> 589 virtual public System.Collections.ArrayList LongLabelRecords 590 { 591 get 592 { 593 lock (this) 594 { 595 return this.longLabelRecords; 596 } 597 } 598 599 set 600 { 601 lock (this) 602 { 603 this.longLabelRecords = value; 441 604 //naptrRecords.Sort(); 442 605 this.updated = (System.DateTime.Now.Ticks - 621355968000000000) / 10000 / 1000; 443 this.setMinTtl(this.nInfoRecords); 444 } 445 } 446 } 606 this.setMinTtl(this.longLabelRecords); 607 608 if (!(this.naptrRecords == null)) 609 { 610 foreach (DNSTelnameNaptrResourceRecord naptr in this.naptrRecords) 611 { 612 foreach (DNSLongLabelTxtResourceRecord label in this.longLabelRecords) 613 { 614 if ((naptr.Order == label.Order) && (naptr.Preference == label.Priority)) 615 { 616 Logger.Log(Logger.Section.Lookups, "Long label matched " + label.TxtStr); 617 naptr.LongLabels = label.LongLabels; 618 } 619 } 620 } 621 } 622 } 623 } 624 } 625 447 626 448 627 … … 452 631 /// <returns> the txt records 453 632 /// </returns> 454 /// <summary> Sets the txt records. 455 /// 633 /// <summary> Sets the txt records. 634 /// Removes and process service messages. Removes keywords. Removes long labels and adds them to their own list. 456 635 /// </summary> 457 636 /// <param name="txtRecords">the txt records … … 471 650 lock (this) 472 651 { 473 this.txtRecords = value; 652 if (this.txtRecords == null) 653 { 654 this.txtRecords = value; 655 } 656 else 657 { 658 this.txtRecords.AddRange(value); 659 } 474 660 Logger.Log(Logger.Section.Lookups, this.txtRecords.Count + " txt entries found."); 475 //txtRecords.Sort();476 661 updated = (System.DateTime.Now.Ticks - 621355968000000000) / 10000 / 1000; 477 662 setMinTtl(this.txtRecords); 478 663 //interpret understood service messages 479 foreach (DNSTxtResourceRecord servmess in this.txtRecords) 480 { 481 if (typeof(DNSTxtServiceMessageResourceRecord).IsInstanceOfType(servmess)) 482 { 483 ((DNSTxtServiceMessageResourceRecord)servmess).Process(this); 484 } 485 } 664 List<DNSTxtResourceRecord> toBeRemoved = new List<DNSTxtResourceRecord>(); 665 ArrayList addLongLabels = new ArrayList(); 666 this.txtRecords.Reverse(); 667 foreach (DNSTxtResourceRecord txtRecord in this.txtRecords) 668 { 669 if (typeof(DNSTxtServiceMessageResourceRecord).IsInstanceOfType(txtRecord)) 670 { 671 ((DNSTxtServiceMessageResourceRecord)txtRecord).Process(this); 672 toBeRemoved.Add((DNSTxtResourceRecord)txtRecord); 673 } 674 if (typeof(DNSLongLabelTxtResourceRecord).IsInstanceOfType(txtRecord)) 675 { 676 addLongLabels.Add((DNSLongLabelTxtResourceRecord)txtRecord); 677 toBeRemoved.Add((DNSTxtResourceRecord)txtRecord); 678 } 679 if (typeof(DNSStructuredKeywordsTxtResourceRecord).IsInstanceOfType(txtRecord)) 680 { 681 toBeRemoved.Add((DNSTxtResourceRecord)txtRecord); 682 } 683 } 684 foreach (DNSTxtResourceRecord o in toBeRemoved) 685 { 686 this.txtRecords.Remove(o); 687 } 688 this.LongLabelRecords = addLongLabels; 689 } 690 } 691 } 692 693 /// <summary> 694 /// Removes and process service messages. Removes keywords. Removes long labels and adds them to their own list. 695 /// </summary> 696 virtual public System.Collections.ArrayList VersionRecords 697 { 698 get 699 { 700 lock (this) 701 { 702 return versionRecords; 703 } 704 } 705 706 set 707 { 708 lock (this) 709 { 710 this.versionRecords = value; 711 this.versionRecords.Reverse() ; 712 updated = (System.DateTime.Now.Ticks - 621355968000000000) / 10000 / 1000; 713 setMinTtl(this.versionRecords); 714 ArrayList toBeRemoved = new ArrayList(); 715 ArrayList pddxRecords = new ArrayList(); 716 ArrayList addKeywords = new ArrayList(); 717 ArrayList addLongLabels = new ArrayList(); 718 foreach (DNSTxtResourceRecord versionRecord in this.versionRecords) 719 { 720 if (typeof(DNSPDDXTxtServiceMessageResourceRecord).IsInstanceOfType(versionRecord)) 721 { 722 Logger.Log(Logger.Section.Lookups, "Version Record Found pddxVersion = " + PddxVersion); 723 pddxRecords.Add((DNSPDDXTxtServiceMessageResourceRecord)versionRecord); 724 ((DNSPDDXTxtServiceMessageResourceRecord)versionRecord).Process(this); 725 Logger.Log(Logger.Section.Lookups, "Version Record Found pddxVersion = " + PddxVersion); 726 toBeRemoved.Add((DNSTxtResourceRecord)versionRecord); 727 } 728 if (typeof(DNSStructuredKeywordsTxtResourceRecord).IsInstanceOfType(versionRecord)) 729 { 730 addKeywords.Add((DNSStructuredKeywordsTxtResourceRecord)versionRecord); 731 toBeRemoved.Add((DNSTxtResourceRecord)versionRecord); 732 } 733 if (typeof(DNSDDSTxtServiceMessageResourceRecord).IsInstanceOfType(versionRecord)) 734 { 735 ((DNSDDSTxtServiceMessageResourceRecord)versionRecord).Process(this); 736 toBeRemoved.Add((DNSTxtResourceRecord)versionRecord); 737 } 738 if (typeof(DNSLongLabelTxtResourceRecord).IsInstanceOfType(versionRecord)) 739 { 740 addLongLabels.Add((DNSLongLabelTxtResourceRecord)versionRecord); 741 toBeRemoved.Add((DNSTxtResourceRecord)versionRecord); 742 } 743 744 } 745 foreach (DNSTxtResourceRecord o in toBeRemoved) 746 { 747 this.versionRecords.Remove(o); 748 } 749 this.txtRecords = this.versionRecords; 750 this.versionRecords = pddxRecords; 751 this.KeywordRecords = addKeywords; 752 this.LongLabelRecords = addLongLabels; 753 } 754 } 755 } 756 757 /// <summary> 758 /// Removes any records which aren't keywords 759 /// </summary> 760 virtual public System.Collections.ArrayList KeywordRecords 761 { 762 get 763 { 764 lock (this) 765 { 766 return keywordRecords; 767 } 768 } 769 770 set 771 { 772 lock (this) 773 { 774 this.keywordRecords = value; 775 //Logger.Log(Logger.Section.Lookups, this.keywordRecords.Count + " keyword entries found when PDDX <> 1."); 776 //txtRecords.Sort(); 777 updated = (System.DateTime.Now.Ticks - 621355968000000000) / 10000 / 1000; 778 setMinTtl(this.keywordRecords); 486 779 //get rid of service messages so they don't get in the way 487 List<DNSTxtServiceMessageResourceRecord> toBeRemoved = new List<DNSTxtServiceMessageResourceRecord>(); 488 foreach (DNSTxtResourceRecord servmess in this.txtRecords) 489 { 490 if (typeof(DNSTxtServiceMessageResourceRecord).IsInstanceOfType(servmess)) 491 { 492 toBeRemoved.Add((DNSTxtServiceMessageResourceRecord)servmess); 493 } 494 } 495 foreach (DNSTxtServiceMessageResourceRecord o in toBeRemoved) 496 { 497 this.txtRecords.Remove(o); 498 } 499 } 500 } 501 502 } 780 List<DNSTxtResourceRecord> toBeRemoved = new List<DNSTxtResourceRecord>(); 781 foreach (DNSTxtResourceRecord txtRecord in this.keywordRecords) 782 { 783 if (!typeof(DNSStructuredKeywordsTxtResourceRecord).IsInstanceOfType(txtRecord)) 784 { 785 toBeRemoved.Add((DNSTxtResourceRecord)txtRecord); 786 } 787 } 788 foreach (DNSTxtResourceRecord o in toBeRemoved) 789 { 790 this.keywordRecords.Remove(o); 791 } 792 793 } 794 } 795 796 } 797 798 799 503 800 504 801 private bool canBeFriended = true; … … 519 816 } 520 817 818 private string pddxVersion = ""; 819 /// <summary> 820 /// The Version found in the PDDX version record 821 /// </summary> 822 public string PddxVersion 823 { 824 get 825 { 826 return this.pddxVersion; 827 } 828 829 set 830 { 831 this.pddxVersion = value; 832 } 833 } 834 835 private string ddsValue = null; 836 /// <summary> 837 /// Returns the vlaue of the DDS 838 /// </summary> 839 public string DdsValue 840 { 841 get 842 { 843 return this.ddsValue; 844 } 845 846 set 847 { 848 this.ddsValue = value; 849 } 850 } 851 521 852 /// <summary> Gets the telname. 522 853 /// … … 625 956 { 626 957 //domainElement.InnerText = this.publicTelname; 958 //string[] crumbs = this.publicTelname.Substring(0, this.publicTelname.Length - 4).Split('.'); 627 959 string[] crumbs = this.publicTelname.Substring(0, this.publicTelname.Length - 4).Split('.'); 628 if (crumbs.Length > 1)629 { 630 if (LookupResult.IsSpecialDomain(crumbs[crumbs.Length - 1]) )960 if (crumbs.Length > 0) 961 { 962 if (LookupResult.IsSpecialDomain(crumbs[crumbs.Length - 1]) && (crumbs.Length > 1)) 631 963 { 632 964 domainElement.InnerText = crumbs[crumbs.Length - 2]; … … 641 973 XmlElement crumbElement = doc.CreateElement("Crumb"); 642 974 XmlElement crumbNameElement = doc.CreateElement("CrumbName"); 643 crumbNameElement.InnerText = crumbs[i];975 crumbNameElement.InnerText = Gnu.Inet.Encoding.IDNA.ToUnicode(crumbs[i]); 644 976 crumbElement.AppendChild(crumbNameElement); 645 977 if (i > 0) … … 674 1006 } 675 1007 1008 if (keywordStatus != LookupWorker.LookupStatus.Ok) 1009 { 1010 XmlElement keywordStatusElement = doc.CreateElement("KeywordErrorStatus"); 1011 keywordStatusElement.InnerText = LookupWorker.FormatStatus(KeywordStatus); 1012 root.AppendChild(keywordStatusElement); 1013 } 1014 676 1015 if (txtStatus != LookupWorker.LookupStatus.Ok) 677 1016 { … … 694 1033 root.AppendChild(nInfoStatusElement); 695 1034 } 696 697 if (this.naptrRecords.Count == 0 && this.locRecords.Count == 0 && this.txtRecords.Count == 0 && this.nInfoRecords.Count == 0)1035 if (this.naptrRecords.Count == 0 && this.locRecords.Count == 0 && this.txtRecords.Count == 0 && (this.nInfoRecords == null || this.nInfoRecords.Count == 0 ) 1036 && (this.keywordRecords == null || this.keywordRecords.Count == 0)) 698 1037 { 699 1038 XmlElement messageElement = doc.CreateElement("Message"); … … 719 1058 root.AppendChild(lastLookUpTimeElement); 720 1059 1060 if (this.ddsValue != null) 1061 { 1062 XmlElement ddsValueElement = doc.CreateElement("ddsValue"); 1063 Logger.Log(Logger.Section.Results_Screen, "DDS - " + this.ddsValue); 1064 ddsValueElement.InnerXml = GetSafeValue(this.ddsValue); 1065 Logger.Log(Logger.Section.Results_Screen, "DDS - " + ddsValueElement.InnerXml); 1066 root.AppendChild(ddsValueElement); 1067 } 1068 1069 721 1070 722 1071 // add the NAPTR results … … 728 1077 foreach (DNSTelnameNaptrResourceRecord rr in NaptrRecords) 729 1078 { 1079 730 1080 if (rr.NonTerminal) 731 1081 { … … 737 1087 naptrRecord.AppendChild(displayElement); 738 1088 1089 Logger.Log(Logger.Section.Results_Screen, "Non terminal: " + rr.ReplaceStr); 739 1090 XmlElement uriElement = doc.CreateElement("Uri"); 740 uriElement.InnerText = rr.ReplaceStr.Replace("\\", "\\\\");1091 uriElement.InnerText = Uri.UnescapeDataString(rr.ReplaceStr).Replace("\\", "\\\\"); 741 1092 naptrRecord.AppendChild(uriElement); 1093 1094 if (rr.LongLabels.Count > 0) 1095 { 1096 XmlElement longLabelsElement = doc.CreateElement("LongLabels"); 1097 foreach (string longLabel in rr.LongLabels) 1098 { 1099 XmlElement longLabelElement = doc.CreateElement("LongLabel"); 1100 XmlElement longLabelNameElement = doc.CreateElement("LongLabelName"); 1101 1102 longLabelNameElement.InnerText = GetSafeValue(longLabel); 1103 longLabelElement.AppendChild(longLabelNameElement); 1104 longLabelsElement.AppendChild(longLabelElement); 1105 } 1106 naptrRecord.AppendChild(longLabelsElement); 1107 } 742 1108 } 743 1109 else 744 1110 { 745 XmlElement naptrRecord = doc.CreateElement("TerminalNaptrRecord"); 746 naptrResultsElement.AppendChild(naptrRecord); 747 748 XmlElement serviceElement = doc.CreateElement("ServiceType"); 749 serviceElement.InnerText = rr.ServiceType; 750 naptrRecord.AppendChild(serviceElement); 751 752 XmlElement serviceNameElement = doc.CreateElement("ServiceName"); 753 serviceNameElement.InnerText = UriHandler.getInstance().ServiceName(rr.ServiceType); 754 naptrRecord.AppendChild(serviceNameElement); 755 756 XmlElement uriElement = doc.CreateElement("Uri"); 757 uriElement.InnerText = rr.Uri.Replace("\\", "\\\\"); 758 naptrRecord.AppendChild(uriElement); 759 760 XmlElement nameElement = doc.CreateElement("Name"); 761 nameElement.InnerText = UriHandler.getInstance().Format(rr.ServiceType, rr.Uri); 762 naptrRecord.AppendChild(nameElement); 763 764 XmlElement categoriesElement = doc.CreateElement("LocationIndicatorHints"); 765 XmlElement categoriesCountElement = doc.CreateElement("Count"); 766 categoriesCountElement.InnerText = rr.Catagories.Count.ToString(); 767 categoriesElement.AppendChild(categoriesCountElement); 768 769 foreach (string lih in rr.Catagories) 770 { 771 XmlElement categoryElement = doc.CreateElement("LocationIndicatorHint"); 772 XmlElement categoryNameElement = doc.CreateElement("Name"); 773 categoryNameElement.InnerText = lih; 774 categoryElement.AppendChild(categoryNameElement); 775 XmlElement categoryPTElement = doc.CreateElement("PresentedText"); 776 categoryPTElement.InnerText = DNSTelnameNaptrResourceRecord.GetLocationIndicatorHintPresentedText(lih); 777 categoryElement.AppendChild(categoryPTElement); 778 categoriesElement.AppendChild(categoryElement); 779 } 780 781 XmlElement concatenatedCategoriesElement = doc.CreateElement("ConcatenatedCategories"); 782 if (rr.Catagories.Count > 0) 783 { 784 string[] cats = rr.Catagories.ToArray(); 785 for (int i = 0; i < cats.Length; i++) 1111 if (UriHandler.getInstance().Launchable(rr.ServiceType) || 1112 (typeof(DNSUnlinkedTelnameNaptrResourceRecord).IsInstanceOfType(rr) && ((DNSUnlinkedTelnameNaptrResourceRecord)rr).Display)) 1113 { 1114 XmlElement naptrRecord = doc.CreateElement("TerminalNaptrRecord"); 1115 naptrResultsElement.AppendChild(naptrRecord); 1116 1117 XmlElement serviceElement = doc.CreateElement("ServiceType"); 1118 serviceElement.InnerText = rr.ServiceType; 1119 naptrRecord.AppendChild(serviceElement); 1120 1121 XmlElement serviceNameElement = doc.CreateElement("ServiceName"); 1122 serviceNameElement.InnerText = UriHandler.getInstance().ServiceName(rr.ServiceType); 1123 naptrRecord.AppendChild(serviceNameElement); 1124 1125 XmlElement uriElement = doc.CreateElement("Uri"); 1126 uriElement.InnerText = rr.Uri.Replace("\\", "\\\\"); 1127 naptrRecord.AppendChild(uriElement); 1128 1129 XmlElement nameElement = doc.CreateElement("Name"); 1130 1131 if (typeof(DNSUnlinkedTelnameNaptrResourceRecord).IsInstanceOfType(rr)) 786 1132 { 787 cats[i] = DNSTelnameNaptrResourceRecord.GetLocationIndicatorHintPresentedText(cats[i]);1133 nameElement.InnerText = ((DNSUnlinkedTelnameNaptrResourceRecord)rr).Text; 788 1134 } 789 concatenatedCategoriesElement.InnerText = String.Join( 790 DotTelSystem.Properties.Resources.LookUpResult_LocationIndicatorHintsSeparator, cats); 791 } 792 else 793 { 794 concatenatedCategoriesElement.InnerText = " "; 795 } 796 categoriesElement.AppendChild(concatenatedCategoriesElement); 797 798 naptrRecord.AppendChild(categoriesElement); 799 800 XmlElement iconElement = doc.CreateElement("Icon"); 801 iconElement.InnerText = UriHandler.getInstance().GetIcon(rr.ServiceType, rr.Catagories, rr.WasEncrypted); 802 naptrRecord.AppendChild(iconElement); 803 804 if (UriHandler.getInstance().Launchable(rr.ServiceType)) 805 { 806 XmlElement launchElement = doc.CreateElement("Launchable"); 807 launchElement.InnerText = "true"; 808 naptrRecord.AppendChild(launchElement); 809 } 810 XmlElement labelsElement = doc.CreateElement("XLabels"); 811 XmlElement xlblCount = doc.CreateElement("Count"); 812 xlblCount.InnerText = rr.Labels.Count.ToString(); 813 labelsElement.AppendChild(xlblCount); 814 foreach (string label in rr.Labels) 815 { 816 XmlElement labelElement = doc.CreateElement("XLabel"); 817 XmlElement labelNameElement = doc.CreateElement("XLabelName"); 818 labelNameElement.InnerText = label.Replace('-', ' ').Replace(':', ' '); 819 labelElement.AppendChild(labelNameElement); 820 labelsElement.AppendChild(labelElement); 821 } 822 naptrRecord.AppendChild(labelsElement); 823 } 1135 else 1136 { 1137 nameElement.InnerText = UriHandler.getInstance().Format(rr.ServiceType, rr.Uri); 1138 XmlElement launchElement = doc.CreateElement("Launchable"); 1139 launchElement.InnerText = "true"; 1140 naptrRecord.AppendChild(launchElement); 1141 } 1142 naptrRecord.AppendChild(nameElement); 1143 1144 XmlElement categoriesElement = doc.CreateElement("LocationIndicatorHints"); 1145 XmlElement categoriesCountElement = doc.CreateElement("Count"); 1146 categoriesCountElement.InnerText = rr.Catagories.Count.ToString(); 1147 categoriesElement.AppendChild(categoriesCountElement); 1148 1149 foreach (string lih in rr.Catagories) 1150 { 1151 XmlElement categoryElement = doc.CreateElement("LocationIndicatorHint"); 1152 XmlElement categoryNameElement = doc.CreateElement("Name"); 1153 categoryNameElement.InnerText = lih; 1154 categoryElement.AppendChild(categoryNameElement); 1155 XmlElement categoryPTElement = doc.CreateElement("PresentedText"); 1156 categoryPTElement.InnerText = DNSTelnameNaptrResourceRecord.GetLocationIndicatorHintPresentedText(lih); 1157 categoryElement.AppendChild(categoryPTElement); 1158 categoriesElement.AppendChild(categoryElement); 1159 } 1160 1161 XmlElement concatenatedCategoriesElement = doc.CreateElement("ConcatenatedCategories"); 1162 if (rr.Catagories.Count > 0) 1163 { 1164 string[] cats = rr.Catagories.ToArray(); 1165 for (int i = 0; i < cats.Length; i++) 1166 { 1167 cats[i] = DNSTelnameNaptrResourceRecord.GetLocationIndicatorHintPresentedText(cats[i]); 1168 } 1169 concatenatedCategoriesElement.InnerText = String.Join( 1170 DotTelSystem.Properties.Resources.LookUpResult_LocationIndicatorHintsSeparator, cats); 1171 } 1172 else 1173 { 1174 concatenatedCategoriesElement.InnerText = " "; 1175 } 1176 categoriesElement.AppendChild(concatenatedCategoriesElement); 1177 1178 naptrRecord.AppendChild(categoriesElement); 1179 1180 XmlElement iconElement = doc.CreateElement("Icon"); 1181 iconElement.InnerText = UriHandler.getInstance().GetIcon(rr.ServiceType, rr.Catagories, rr.WasEncrypted); 1182 naptrRecord.AppendChild(iconElement); 1183 1184 XmlElement labelsElement = doc.CreateElement("XLabels"); 1185 XmlElement xlblCount = doc.CreateElement("Count"); 1186 xlblCount.InnerText = rr.Labels.Count.ToString(); 1187 labelsElement.AppendChild(xlblCount); 1188 foreach (string label in rr.Labels) 1189 { 1190 XmlElement labelElement = doc.CreateElement("XLabel"); 1191 XmlElement labelNameElement = doc.CreateElement("XLabelName"); 1192 labelNameElement.InnerText = GetSafeValue(label).Replace('-', ' ').Replace(':', ' '); 1193 labelElement.AppendChild(labelNameElement); 1194 labelsElement.AppendChild(labelElement); 1195 } 1196 naptrRecord.AppendChild(labelsElement); 1197 1198 if (rr.LongLabels.Count > 0) 1199 { 1200 Logger.Log(Logger.Section.Results_Screen, "Long Label count: " + rr.LongLabels.Count); 1201 XmlElement longLabelsElement = doc.CreateElement("LongLabels"); 1202 foreach (string longLabel in rr.LongLabels) 1203 { 1204 XmlElement longLabelElement = doc.CreateElement("LongLabel"); 1205 XmlElement longLabelNameElement = doc.CreateElement("LongLabelName"); 1206 longLabelNameElement.InnerText = GetSafeValue(longLabel); 1207 longLabelElement.AppendChild(longLabelNameElement); 1208 longLabelsElement.AppendChild(longLabelElement); 1209 } 1210 naptrRecord.AppendChild(longLabelsElement); 1211 } 1212 1213 1214 } 1215 1216 } 1217 824 1218 } 825 1219 … … 856 1250 857 1251 // add the TXT results 858 XmlElement txtResultsElement = doc.CreateElement("TxtResults"); 859 root.AppendChild(txtResultsElement); 860 861 if (TxtRecords != null) 862 { 863 foreach (DNSTxtResourceRecord rr in TxtRecords) 1252 //Commented out because we shouldn't be displaying an txtRecords 1253 if (pddxVersion == "1") 1254 { 1255 XmlElement txtResultsElement = doc.CreateElement("TxtResults"); 1256 root.AppendChild(txtResultsElement); 1257 1258 if (TxtRecords != null) 1259 { 1260 foreach (DNSTxtResourceRecord rr in TxtRecords) 1261 { 1262 if (!typeof(DNSEnhancedTxtResourceRecord).IsInstanceOfType(rr)) 1263 { 1264 XmlElement txtRecord = doc.CreateElement("TxtRecord"); 1265 txtResultsElement.AppendChild(txtRecord); 1266 1267 XmlElement stringElement = doc.CreateElement("String"); 1268 stringElement.InnerText = stringElement.InnerText = GetSafeValue(rr.TxtStr); 1269 txtRecord.AppendChild(stringElement); 1270 } 1271 } 1272 } 1273 } 1274 1275 // add the Keyword results 1276 XmlElement keywordResultsElement = doc.CreateElement("KeywordResults"); 1277 root.AppendChild(keywordResultsElement); 1278 1279 if (KeywordRecords != null) 1280 { 1281 foreach (DNSTxtResourceRecord rr in KeywordRecords) 864 1282 { 865 1283 if (typeof(DNSEnhancedTxtResourceRecord).IsInstanceOfType(rr)) … … 867 1285 if (typeof(DNSStructuredKeywordsTxtResourceRecord).IsInstanceOfType(rr)) 868 1286 { 869 XmlElement txtRecord = doc.CreateElement("EnhancedTxtRecord");870 txtResultsElement.AppendChild(txtRecord);1287 XmlElement keywordRecord = doc.CreateElement("EnhancedTxtRecord"); 1288 keywordResultsElement.AppendChild(keywordRecord); 871 1289 872 1290 DNSStructuredKeywordsTxtResourceRecord dnssktrr = (DNSStructuredKeywordsTxtResourceRecord)rr; 873 1291 1292 if (dnssktrr.FreeText != null) 1293 { 1294 XmlElement typeElement = doc.CreateElement("Type"); 1295 typeElement.InnerText = "FreeText"; 1296 keywordRecord.AppendChild(typeElement); 1297 1298 XmlElement pairElement = doc.CreateElement("PrimaryPair"); 1299 XmlElement keyElement = doc.CreateElement("Key"); 1300 keyElement.InnerText = ""; 1301 pairElement.AppendChild(keyElement); 1302 1303 string value = GetSafeValue(dnssktrr.FreeText); 1304 //string value = System.Security.SecurityElement.Escape(StripCharactersHTMLFears(dnssktrr.FreeText)); 1305 if (value != "") 1306 { 1307 XmlElement valueElement = doc.CreateElement("Value"); 1308 valueElement.InnerText = value; 1309 pairElement.AppendChild(valueElement); 1310 } 1311 keywordRecord.AppendChild(pairElement); 1312 } 1313 } 1314 } 1315 } 1316 foreach (DNSTxtResourceRecord rr in KeywordRecords) 1317 { 1318 if (typeof(DNSEnhancedTxtResourceRecord).IsInstanceOfType(rr)) 1319 { 1320 if (typeof(DNSStructuredKeywordsTxtResourceRecord).IsInstanceOfType(rr)) 1321 { 1322 XmlElement keywordRecord = doc.CreateElement("EnhancedTxtRecord"); 1323 keywordResultsElement.AppendChild(keywordRecord); 1324 1325 DNSStructuredKeywordsTxtResourceRecord dnssktrr = (DNSStructuredKeywordsTxtResourceRecord)rr; 1326 874 1327 XmlElement countElement = doc.CreateElement("Count"); 875 countElement.InnerText = "" + dnssktrr. OrderOfKeys.Count;876 txtRecord.AppendChild(countElement);1328 countElement.InnerText = "" + dnssktrr.KeywordsAndValues.Count; 1329 keywordRecord.AppendChild(countElement); 877 1330 bool primary = true; 878 foreach ( string key in dnssktrr.OrderOfKeys)1331 foreach (KeyValuePair<string, string> kvp in dnssktrr.KeywordsAndValues) 879 1332 { 1333 XmlElement typeElement = doc.CreateElement("Type"); 1334 if (dnssktrr.IsStructured()) 1335 { 1336 typeElement.InnerText = "Structured"; 1337 } 1338 else 1339 { 1340 typeElement.InnerText = "Other"; 1341 } 1342 keywordRecord.AppendChild(typeElement); 1343 1344 //string key = System.Security.SecurityElement.Escape(StripCharactersHTMLFears(kvp.Key)); 1345 //string value = System.Security.SecurityElement.Escape(StripCharactersHTMLFears(kvp.Value)); 1346 string key = GetSafeValue(kvp.Key); 1347 string value = GetSafeValue(kvp.Value); 880 1348 XmlElement pairElement = null; 881 if (primary )1349 if (primary && dnssktrr.IsStructured()) 882 1350 { 883 1351 primary = false; … … 888 1356 pairElement = doc.CreateElement("Pair"); 889 1357 } 890 891 1358 XmlElement keyElement = doc.CreateElement("Key"); 892 keyElement.InnerText = StripCharactersHTMLFears(key);1359 keyElement.InnerText = key; 893 1360 pairElement.AppendChild(keyElement); 894 1361 Logger.Log(Logger.Section.Results_Screen,"Key: " + key); 895 1362 XmlElement keyNameElement = doc.CreateElement("Key-name"); 896 keyNameElement.InnerText = dnssktrr.KeysToHumanReadableValues[StripCharactersHTMLFears(key)]; 1363 keyNameElement.InnerText = dnssktrr.KeysToHumanReadableValues[kvp.Key]; 1364 1365 897 1366 pairElement.AppendChild(keyNameElement); 898 1367 899 string value = dnssktrr.KeywordsAndValues[StripCharactersHTMLFears(key)];900 1368 if (value != "") 901 1369 { 902 1370 XmlElement valueElement = doc.CreateElement("Value"); 903 valueElement.InnerText = value; 1371 if (value.EndsWith(":")) 1372 { 1373 valueElement.InnerText = value.Substring(0,value.Length-1); 1374 } 1375 else 1376 { 1377 valueElement.InnerText = value; 1378 } 1379 904 1380 pairElement.AppendChild(valueElement); 905 1381 } 906 1382 907 txtRecord.AppendChild(pairElement); 1383 keywordRecord.AppendChild(pairElement); 1384 908 1385 } 909 1386 } 910 911 }912 else913 {914 XmlElement txtRecord = doc.CreateElement("TxtRecord");915 txtResultsElement.AppendChild(txtRecord);916 917 XmlElement stringElement = doc.CreateElement("String");918 stringElement.InnerText = System.Security.SecurityElement.Escape(StripCharactersHTMLFears(rr.TxtStr))919 .Replace("\r\n", "<br />").Replace("\n", "<br />").Replace("\r", "<br />").Replace("'", "'");920 txtRecord.AppendChild(stringElement);921 1387 } 922 1388 } … … 934 1400 935 1401 XmlElement stringElement = doc.CreateElement("String"); 936 stringElement.InnerText = System.Security.SecurityElement.Escape(StripCharactersHTMLFears(rr.TxtStr)) 937 .Replace("\r\n", "<br />").Replace("\n", "<br />").Replace("\r", "<br />").Replace("'", "'"); 1402 stringElement.InnerText = GetSafeValue(rr.TxtStr); 1403 //stringElement.InnerText = System.Security.SecurityElement.Escape(StripCharactersHTMLFears(rr.TxtStr)) 1404 // .Replace("\r\n", "<br />").Replace("\n", "<br />").Replace("\r", "<br />").Replace("'", "'"); 938 1405 nInfoRecord.AppendChild(stringElement); 939 1406 } 940 1407 } 941 942 1408 return root; 943 1409 944 1410 } 1411 1412 private string GetSafeValue(string p) 1413 { 1414 return System.Security.SecurityElement.Escape(StripCharactersHTMLFears(p)) 1415 .Replace("\r\n", "<br />").Replace("\n", "<br />").Replace("\r", "<br />") 1416 .Replace("'", "'"); 1417 } 1418 1419 /*private static void MakeLabelText(string label, XmlElement labelNameElement) 1420 { 1421 labelNameElement.InnerText = System.Security.SecurityElement.Escape(StripCharactersHTMLFears(label)) 1422 .Replace("\r\n", "<br />").Replace("\n", "<br />").Replace("\r", "<br />") 1423 .Replace("'", "'").Replace('-', ' ').Replace(':', ' '); 1424 }*/ 945 1425 946 1426 … … 980 1460 } 981 1461 } 1462 1463 982 1464 } 983 1465 } -
apps/outlook/branches/1.6/DotTelSystem/Lookup/LookupTelname.cs
r338 r646 58 58 public class LookupTelname : LookupWorkerCompletedListener 59 59 { 60 60 61 61 /// <summary> Sets the listener. 62 62 /// … … 101 101 private LookupWorker lwTxt; 102 102 103 /// <summary> The lw txt.</summary>103 /// <summary> The lw ninfo.</summary> 104 104 private LookupWorker lwNInfo; 105 106 /// <summary> The lw kw.</summary> 107 private LookupWorker lwKeyword; 108 109 /// <summary> The lw version.</summary> 110 private LookupWorker lwVersion; 105 111 106 112 /// <summary> The lookup result.</summary> … … 136 142 /// <summary> The status.</summary> 137 143 private int status = STATUS_OK; 144 145 /// <summary> The version at which we change lookups</summary> 146 private const int version_change = 11; 138 147 139 148 private Thread naptrThread; … … 141 150 private Thread txtThread; 142 151 private Thread nInfoThread; 152 private Thread keywordThread; 153 private Thread versionThread; 143 154 144 155 public LookupWorker.LookupStatus parentStatus; … … 191 202 else if (!cancelled) 192 203 { 193 // do txt and naptr lookups in separate threads 194 performTxtLookup(publicTelname); 195 performLocLookup(publicTelname); 196 performNaptrLookup(telname); 197 performNInfoLookup(publicTelname); 198 199 // wait for those threads to finish 200 naptrThread.Join(); 201 locThread.Join(); 202 txtThread.Join(); 203 nInfoThread.Join(); 204 205 Logger.Log(Logger.Section.Lookups, "Lookup threads finished for " + telname); 206 Logger.Log(Logger.Section.Lookups, "NAPTR Status: " + lookupResult.NaptrStatus); 207 Logger.Log(Logger.Section.Lookups, "LOC Status: " + lookupResult.LocStatus); 208 Logger.Log(Logger.Section.Lookups, "TXT Status: " + lookupResult.TxtStatus); 209 Logger.Log(Logger.Section.Lookups, "NInfo Status: " + lookupResult.NInfoStatus); 210 211 // check if the lookup status was OK 212 if (!cancelled && lookupResult.LocStatus == LookupWorker.LookupStatus.Ok && 213 lookupResult.TxtStatus == LookupWorker.LookupStatus.Ok && 214 lookupResult.NaptrStatus == LookupWorker.LookupStatus.Ok && 215 lookupResult.NInfoStatus == LookupWorker.LookupStatus.Ok) 216 { 217 // store result in cache 218 LookupCache.SetResult(telname, lookupResult); 219 complete = true; 220 completeListener.LookupTelnameComplete(lookupResult); 221 } 222 // if the result was NXDomain then remove the cache! 223 else if (!cancelled && (lookupResult.NaptrStatus == LookupWorker.LookupStatus.Nxdomain || 224 lookupResult.LocStatus == LookupWorker.LookupStatus.Nxdomain || 225 lookupResult.TxtStatus == LookupWorker.LookupStatus.Nxdomain || 226 lookupResult.NInfoStatus == LookupWorker.LookupStatus.Nxdomain)) 227 { 228 LookupCache.RemoveResult(telname); 229 complete = true; 230 completeListener.LookupTelnameComplete(lookupResult); 231 } 232 233 // lookup result is not OK, return the cached result 234 else if (!cancelled && cachedResult != null) 235 { 236 // return the cached result, but set the status to the status of the actual lookup 237 // so that the user will know why they are seeing the cached results 238 complete = true; 239 cachedResult.TxtStatus = lookupResult.TxtStatus; 240 cachedResult.NaptrStatus = lookupResult.NaptrStatus; 241 cachedResult.LocStatus = lookupResult.LocStatus; 242 cachedResult.NInfoStatus = lookupResult.NInfoStatus; 243 completeListener.LookupTelnameComplete(cachedResult); 244 } 245 else if (!cancelled) 246 { 247 completeListener.LookupTelnameComplete(lookupResult); 248 } 249 } 250 } 204 int version = GetVersion(publicTelname); 205 206 if (version < version_change) 207 { 208 Logger.Log(Logger.Section.Lookups, "version " + version ); 209 if (publicTelname == telname) 210 { 211 Logger.Log(Logger.Section.Lookups, "public"); 212 DoVersionOneLookupAndCache(publicTelname); 213 } 214 else 215 { 216 Logger.Log(Logger.Section.Lookups, "private "); 217 DoVersionOneLookupAndCachePrivate(publicTelname, telname); 218 } 219 } 220 else 221 { 222 Logger.Log(Logger.Section.Lookups, "version " + version); 223 DoLookupAndCache(publicTelname, telname); 224 } 225 226 } 227 } 228 229 /// <summary> 230 /// Performs both public and private lookup and caching for version 1.1 onwards 231 /// </summary> 232 /// <param name="publicTelname">the public telname</param> 233 /// <param name="telname">the private telname</param> 234 private void DoLookupAndCache(string publicTelname, string telname) 235 { 236 // do txt and naptr lookups in separate threads 237 performTxtLookup(telname); 238 performLocLookup(telname); 239 performNaptrLookup(telname); 240 performNInfoLookup(telname); 241 performKeywordLookup("_kw." + publicTelname); 242 243 // wait for those threads to finish 244 naptrThread.Join(); 245 locThread.Join(); 246 txtThread.Join(); 247 nInfoThread.Join(); 248 keywordThread.Join(); 249 250 Logger.Log(Logger.Section.Lookups, "Lookup threads finished for " + telname); 251 Logger.Log(Logger.Section.Lookups, "NAPTR Status: " + lookupResult.NaptrStatus); 252 Logger.Log(Logger.Section.Lookups, "LOC Status: " + lookupResult.LocStatus); 253 Logger.Log(Logger.Section.Lookups, "TXT Status: " + lookupResult.TxtStatus); 254 Logger.Log(Logger.Section.Lookups, "NInfo Status: " + lookupResult.NInfoStatus); 255 Logger.Log(Logger.Section.Lookups, "Keyword Status: " + lookupResult.KeywordStatus); 256 Logger.Log(Logger.Section.Lookups, "Version Status: " + lookupResult.VersionStatus); 257 258 // check if the lookup status was OK 259 if (!cancelled && lookupResult.LocStatus == LookupWorker.LookupStatus.Ok && 260 lookupResult.TxtStatus == LookupWorker.LookupStatus.Ok && 261 lookupResult.NaptrStatus == LookupWorker.LookupStatus.Ok && 262 lookupResult.NInfoStatus == LookupWorker.LookupStatus.Ok && 263 lookupResult.KeywordStatus == LookupWorker.LookupStatus.Ok && 264 lookupResult.VersionStatus == LookupWorker.LookupStatus.Ok) 265 { 266 // store result in cache 267 LookupCache.SetResult(telname, lookupResult); 268 complete = true; 269 completeListener.LookupTelnameComplete(lookupResult); 270 } 271 // if the result was NXDomain then remove the cache! 272 else if (!cancelled && (lookupResult.NaptrStatus == LookupWorker.LookupStatus.Nxdomain || 273 lookupResult.LocStatus == LookupWorker.LookupStatus.Nxdomain || 274 lookupResult.TxtStatus == LookupWorker.LookupStatus.Nxdomain || 275 lookupResult.KeywordStatus == LookupWorker.LookupStatus.Nxdomain || 276 lookupResult.VersionStatus == LookupWorker.LookupStatus.Nxdomain || 277 lookupResult.NInfoStatus == LookupWorker.LookupStatus.Nxdomain)) 278 { 279 LookupCache.RemoveResult(telname); 280 complete = true; 281 completeListener.LookupTelnameComplete(lookupResult); 282 } 283 // lookup result is not OK, return the cached result 284 else if (!cancelled && cachedResult != null) 285 { 286 // return the cached result, but set the status to the status of the actual lookup 287 // so that the user will know why they are seeing the cached results 288 complete = true; 289 cachedResult.TxtStatus = lookupResult.TxtStatus; 290 cachedResult.NaptrStatus = lookupResult.NaptrStatus; 291 cachedResult.LocStatus = lookupResult.LocStatus; 292 cachedResult.NInfoStatus = lookupResult.NInfoStatus; 293 cachedResult.KeywordStatus = lookupResult.KeywordStatus; 294 cachedResult.VersionStatus = lookupResult.VersionStatus; 295 completeListener.LookupTelnameComplete(cachedResult); 296 } 297 else if (!cancelled) 298 { 299 completeListener.LookupTelnameComplete(lookupResult); 300 } 301 } 302 303 /// <summary> 304 /// Perform public lookup on version one 305 /// </summary> 306 /// <param name="publicTelname">the public telname</param> 307 private void DoVersionOneLookupAndCache(string publicTelname) 308 { 309 // do txt and naptr lookups in separate threads 310 performLocLookup(publicTelname); 311 performNaptrLookup(publicTelname); 312 313 // wait for those threads to finish 314 naptrThread.Join(); 315 locThread.Join(); 316 317 Logger.Log(Logger.Section.Lookups, "Lookup threads finished for " + telname); 318 Logger.Log(Logger.Section.Lookups, "NAPTR Status: " + lookupResult.NaptrStatus); 319 Logger.Log(Logger.Section.Lookups, "LOC Status: " + lookupResult.LocStatus); 320 Logger.Log(Logger.Section.Lookups, "Version Status: " + lookupResult.VersionStatus); 321 322 // check if the lookup status was OK 323 if (!cancelled && lookupResult.LocStatus == LookupWorker.LookupStatus.Ok && 324 lookupResult.NaptrStatus == LookupWorker.LookupStatus.Ok && 325 lookupResult.VersionStatus == LookupWorker.LookupStatus.Ok) 326 { 327 // store result in cache 328 LookupCache.SetResult(telname, lookupResult); 329 complete = true; 330 completeListener.LookupTelnameComplete(lookupResult); 331 } 332 // if the result was NXDomain then remove the cache! 333 else if (!cancelled && (lookupResult.NaptrStatus == LookupWorker.LookupStatus.Nxdomain || 334 lookupResult.LocStatus == LookupWorker.LookupStatus.Nxdomain || 335 lookupResult.VersionStatus == LookupWorker.LookupStatus.Nxdomain)) 336 { 337 LookupCache.RemoveResult(telname); 338 complete = true; 339 completeListener.LookupTelnameComplete(lookupResult); 340 } 341 // lookup result is not OK, return the cached result 342 else if (!cancelled && cachedResult != null) 343 { 344 // return the cached result, but set the status to the status of the actual lookup 345 // so that the user will know why they are seeing the cached results 346 complete = true; 347 cachedResult.TxtStatus = lookupResult.TxtStatus; 348 cachedResult.NaptrStatus = lookupResult.NaptrStatus; 349 cachedResult.LocStatus = lookupResult.LocStatus; 350 cachedResult.VersionStatus = lookupResult.VersionStatus; 351 completeListener.LookupTelnameComplete(cachedResult); 352 } 353 else if (!cancelled) 354 { 355 completeListener.LookupTelnameComplete(lookupResult); 356 } 357 } 358 359 /// <summary> 360 /// Performs private lookup on version 1 361 /// </summary> 362 /// <param name="publicTelname"> the public telname</param> 363 /// <param name="telname">the private telname</param> 364 private void DoVersionOneLookupAndCachePrivate(string publicTelname, string telname) 365 { 366 // do txt and naptr lookups in separate threads 367 performTxtLookup(telname); 368 performLocLookup(publicTelname); 369 performNaptrLookup(telname); 370 371 // wait for those threads to finish 372 naptrThread.Join(); 373 locThread.Join(); 374 txtThread.Join(); 375 376 Logger.Log(Logger.Section.Lookups, "Lookup threads finished for " + telname); 377 Logger.Log(Logger.Section.Lookups, "NAPTR Status: " + lookupResult.NaptrStatus); 378 Logger.Log(Logger.Section.Lookups, "LOC Status: " + lookupResult.LocStatus); 379 Logger.Log(Logger.Section.Lookups, "TXT Status: " + lookupResult.TxtStatus); 380 Logger.Log(Logger.Section.Lookups, "Version Status: " + lookupResult.VersionStatus); 381 382 // check if the lookup status was OK 383 if (!cancelled && lookupResult.LocStatus == LookupWorker.LookupStatus.Ok && 384 lookupResult.TxtStatus == LookupWorker.LookupStatus.Ok && 385 lookupResult.NaptrStatus == LookupWorker.LookupStatus.Ok && 386 lookupResult.VersionStatus == LookupWorker.LookupStatus.Ok) 387 { 388 // store result in cache 389 LookupCache.SetResult(telname, lookupResult); 390 complete = true; 391 completeListener.LookupTelnameComplete(lookupResult); 392 } 393 // if the result was NXDomain then remove the cache! 394 else if (!cancelled && (lookupResult.NaptrStatus == LookupWorker.LookupStatus.Nxdomain || 395 lookupResult.LocStatus == LookupWorker.LookupStatus.Nxdomain || 396 lookupResult.TxtStatus == LookupWorker.LookupStatus.Nxdomain || 397 lookupResult.VersionStatus == LookupWorker.LookupStatus.Nxdomain)) 398 { 399 LookupCache.RemoveResult(telname); 400 complete = true; 401 completeListener.LookupTelnameComplete(lookupResult); 402 } 403 // lookup result is not OK, return the cached result 404 else if (!cancelled && cachedResult != null) 405 { 406 // return the cached result, but set the status to the status of the actual lookup 407 // so that the user will know why they are seeing the cached results 408 complete = true; 409 cachedResult.TxtStatus = lookupResult.TxtStatus; 410 cachedResult.NaptrStatus = lookupResult.NaptrStatus; 411 cachedResult.LocStatus = lookupResult.LocStatus; 412 cachedResult.VersionStatus = lookupResult.VersionStatus; 413 completeListener.LookupTelnameComplete(cachedResult); 414 } 415 else if (!cancelled) 416 { 417 completeListener.LookupTelnameComplete(lookupResult); 418 } 419 } 420 251 421 252 422 … … 260 430 if (!cancelled) 261 431 { 262 lwNaptr = new LookupWorker(telnameVal, DNS.DnsQueryType.Naptr, address, port );432 lwNaptr = new LookupWorker(telnameVal, DNS.DnsQueryType.Naptr, address, port, TelnicLookupType.Naptr); 263 433 } 264 434 if (!cancelled) … … 283 453 if (!cancelled) 284 454 { 285 lwLoc = new LookupWorker(telnameVal, DNS.DnsQueryType.Loc, address, port );455 lwLoc = new LookupWorker(telnameVal, DNS.DnsQueryType.Loc, address, port, TelnicLookupType.Location); 286 456 } 287 457 if (!cancelled) … … 306 476 if (!cancelled) 307 477 { 308 lwTxt = new LookupWorker(telnameVal, DNS.DnsQueryType.Txt, address, port );478 lwTxt = new LookupWorker(telnameVal, DNS.DnsQueryType.Txt, address, port, TelnicLookupType.LongLabelAndServiceMessage); 309 479 } 310 480 if (!cancelled) … … 321 491 } 322 492 493 494 /// <summary> Perform Version lookup. 495 /// 496 /// </summary> 497 /// <param name="telname">the telname 498 /// </param> 499 private void performVersionLookup(string telnameVal) 500 { 501 if (!cancelled) 502 { 503 lwVersion = new LookupWorker(telnameVal, DNS.DnsQueryType.Txt, address, port, TelnicLookupType.Version); 504 } 505 if (!cancelled) 506 { 507 lwVersion.LookupWorkerCompletedListener = this; 508 } 509 if (!cancelled) 510 { 511 versionThread = new Thread(lwVersion.Run); 512 versionThread.Name = "Version Thread"; 513 versionThread.Start(); 514 } 515 } 516 517 /// <summary> 518 /// Perform Ninfo Lookup 519 /// </summary> 520 /// <param name="telnameVal"> the telname</param> 323 521 private void performNInfoLookup(string telnameVal) 324 522 { 325 523 if (!cancelled) 326 524 { 327 lwNInfo = new LookupWorker(telnameVal, DNS.DnsQueryType.Ninfo, address, port );525 lwNInfo = new LookupWorker(telnameVal, DNS.DnsQueryType.Ninfo, address, port, TelnicLookupType.HeaderText); 328 526 } 329 527 if (!cancelled) … … 341 539 342 540 /// <summary> 541 /// Perform keyword lookup 542 /// </summary> 543 /// <param name="telnameVal">the telname</param> 544 private void performKeywordLookup(string telnameVal) 545 { 546 if (!cancelled) 547 { 548 lwKeyword = new LookupWorker(telnameVal, DNS.DnsQueryType.Txt, address, port, TelnicLookupType.Keyword); 549 } 550 if (!cancelled) 551 { 552 lwKeyword.LookupWorkerCompletedListener = this; 553 } 554 if (!cancelled) 555 { 556 keywordThread = new Thread(lwKeyword.Run); 557 keywordThread.Name = "Keyword Thread"; 558 keywordThread.Start(); 559 560 } 561 } 562 563 /// <summary> 343 564 /// Adds the results to the lookup results according to the type of the query 344 565 /// </summary> … … 346 567 /// <param name="type">The type of lookup performed</param> 347 568 /// <param name="answers"></param> 348 public virtual void lookupWorkerCompleted(LookupWorker.LookupStatus statusVal, DNS.DnsQueryType type, System.Collections.ArrayList answers )569 public virtual void lookupWorkerCompleted(LookupWorker.LookupStatus statusVal, DNS.DnsQueryType type, System.Collections.ArrayList answers, TelnicLookupType telnicType) 349 570 { 350 571 if (type == DNS.DnsQueryType.Txt) 351 572 { 352 if (statusVal == LookupWorker.LookupStatus.Ok) 353 { 354 lookupResult.TxtRecords = answers; 573 if (telnicType == TelnicLookupType.Keyword) 574 { 575 if (statusVal == LookupWorker.LookupStatus.Ok) 576 { 577 lookupResult.KeywordRecords = answers; 578 } 579 else 580 { 581 lookupResult.KeywordRecords = new System.Collections.ArrayList(); 582 } 583 584 lookupResult.KeywordStatus = statusVal; 585 return; 586 } 587 else if (telnicType == TelnicLookupType.Version) 588 { 589 if (statusVal == LookupWorker.LookupStatus.Ok) 590 { 591 lookupResult.VersionRecords = answers; 592 } 593 else 594 { 595 lookupResult.VersionRecords = new System.Collections.ArrayList(); 596 } 597 598 lookupResult.VersionStatus = statusVal; 599 return; 355 600 } 356 601 else 357 602 { 358 lookupResult.TxtRecords = new System.Collections.ArrayList(); 359 } 360 361 lookupResult.TxtStatus = statusVal; 362 return; 603 if (statusVal == LookupWorker.LookupStatus.Ok) 604 { 605 lookupResult.TxtRecords = answers; 606 } 607 else 608 { 609 lookupResult.TxtRecords = new System.Collections.ArrayList(); 610 } 611 612 lookupResult.TxtStatus = statusVal; 613 return; 614 } 363 615 } 364 616 else if (type == DNS.DnsQueryType.Loc) … … 429 681 lwNInfo = null; 430 682 } 683 if (lwKeyword != null) 684 { 685 lwKeyword = null; 686 } 687 if (lwVersion != null) 688 { 689 lwVersion = null; 690 } 431 691 432 692 this.status = STATUS_CANCELLED; … … 436 696 } 437 697 } 698 699 /// <summary> 700 /// Do a public text lookup to get the pddx version to decide what further lookups to do 701 /// </summary> 702 /// <param name="telname">the public telname</param> 703 /// <returns>the pddx version eg "1" or "11"</returns> 704 private int GetVersion(string telname) 705 { 706 performVersionLookup(telname); 707 versionThread.Join(); 708 Logger.Log(Logger.Section.Lookups, "Version Status: " + lookupResult.VersionStatus); 709 if (lookupResult.VersionStatus == LookupWorker.LookupStatus.Ok) 710 { 711 Logger.Log(Logger.Section.Lookups, "PDDX Version (in getVersion) is: " + lookupResult.PddxVersion); 712 string pddx = lookupResult.PddxVersion; 713 if (pddx.Length == 1) 714 pddx = pddx + "0"; 715 try 716 { 717 return int.Parse(pddx); 718 } 719 catch (Exception e) 720 { 721 return version_change; 722 } 723 724 } 725 return version_change; 726 } 438 727 } 439 728 } -
apps/outlook/branches/1.6/DotTel/ThisAddIn.cs
r493 r646 91 91 get 92 92 { 93 return "1. 4";93 return "1.6"; 94 94 } 95 95 }








