Source/AIURLHandlerPlugin.m
branchadium-1.5.10.4
changeset 5983 a98704da1923
parent 5963 a1d5ba1db0a6
equal deleted inserted replaced
5982:e58f535ef9d2 5983:a98704da1923
   136 {
   136 {
   137 	static NSDictionary	*schemeToServiceDict = nil;
   137 	static NSDictionary	*schemeToServiceDict = nil;
   138 	if (!schemeToServiceDict) {
   138 	if (!schemeToServiceDict) {
   139 		schemeToServiceDict = [[NSDictionary alloc] initWithObjectsAndKeys:
   139 		schemeToServiceDict = [[NSDictionary alloc] initWithObjectsAndKeys:
   140 							   @"AIM",     @"aim",
   140 							   @"AIM",     @"aim",
   141 							   @"Yahoo!",  @"ymsgr",
       
   142 							   @"Yahoo!",  @"yahoo",
       
   143 							   @"Jabber",  @"xmpp",
   141 							   @"Jabber",  @"xmpp",
   144 							   @"Jabber",  @"jabber",
   142 							   @"Jabber",  @"jabber",
   145 							   @"GTalk",   @"gtalk",
   143 							   @"GTalk",   @"gtalk",
   146 							   @"MSN",     @"msn",
       
   147 							   @"IRC",	   @"irc",
   144 							   @"IRC",	   @"irc",
   148 							   nil];
   145 							   nil];
   149 	}
   146 	}
   150 	
   147 	
   151 	return [schemeToServiceDict objectForKey:scheme];
   148 	return [schemeToServiceDict objectForKey:scheme];
   152 }
   149 }
   153 
   150 
   154 /*!
   151 /*!
   155  * @brief All of the schemes similar to a given scheme
   152  * @brief All of the schemes similar to a given scheme
   156  *
   153  *
   157  * Several services (such as Yahoo and Jabber) have several scheme
   154  * Several services (such as Jabber) have several scheme
   158  * aliases which are possible schemes for them. Instead of having multiple
   155  * aliases which are possible schemes for them. Instead of having multiple
   159  * entries each, we simply use a reference one and apply to all aliases.
   156  * entries each, we simply use a reference one and apply to all aliases.
   160  *
   157  *
   161  * @param scheme A reference scheme (see -uniqueSchemes)
   158  * @param scheme A reference scheme (see -uniqueSchemes)
   162  * @returns An NSArray of all schemes similar to the given one.
   159  * @returns An NSArray of all schemes similar to the given one.
   163  */
   160  */
   164 - (NSArray *)allSchemesLikeScheme:(NSString *)scheme
   161 - (NSArray *)allSchemesLikeScheme:(NSString *)scheme
   165 {
   162 {
   166 	if ([scheme isEqualToString:@"ymsgr"]) {
   163 	if ([scheme isEqualToString:@"xmpp"]) {
   167 		return [NSArray arrayWithObjects:@"yahoo", @"ymsgr", nil];
       
   168 	} else if ([scheme isEqualToString:@"xmpp"]) {
       
   169 		return [NSArray arrayWithObjects:@"xmpp", @"jabber", @"gtalk", nil];
   164 		return [NSArray arrayWithObjects:@"xmpp", @"jabber", @"gtalk", nil];
   170 	} else {
   165 	} else {
   171 		return [NSArray arrayWithObject:scheme];
   166 		return [NSArray arrayWithObject:scheme];
   172 	}
   167 	}
   173 }
   168 }
   177  *
   172  *
   178  * @returns An NSArray of all of the schemes we support.
   173  * @returns An NSArray of all of the schemes we support.
   179  */
   174  */
   180 - (NSArray *)uniqueSchemes
   175 - (NSArray *)uniqueSchemes
   181 {
   176 {
   182 	return [NSArray arrayWithObjects:@"aim", @"irc", @"xmpp", @"msn", @"msim", @"ymsgr", nil];
   177 	return [NSArray arrayWithObjects:@"aim", @"irc", @"xmpp", nil];
   183 }
   178 }
   184 
   179 
   185 /*!
   180 /*!
   186  * @brief Helper schemes
   181  * @brief Helper schemes
   187  *
   182  *
   250 	
   245 	
   251 	//map schemes to common aliases (like jabber: for xmpp:).
   246 	//map schemes to common aliases (like jabber: for xmpp:).
   252 	static NSDictionary *schemeMappingDict = nil;
   247 	static NSDictionary *schemeMappingDict = nil;
   253 	if (!schemeMappingDict) {
   248 	if (!schemeMappingDict) {
   254 		schemeMappingDict = [[NSDictionary alloc] initWithObjectsAndKeys:
   249 		schemeMappingDict = [[NSDictionary alloc] initWithObjectsAndKeys:
   255 							 @"ymsgr", @"yahoo",
       
   256 							 @"xmpp", @"jabber",
   250 							 @"xmpp", @"jabber",
   257 							 nil];
   251 							 nil];
   258 	}
   252 	}
   259 	
   253 	
   260 	newScheme = [schemeMappingDict objectForKey:scheme];
   254 	newScheme = [schemeMappingDict objectForKey:scheme];
   469 			NSString	*user = [url user];
   463 			NSString	*user = [url user];
   470 			NSString	*ircHost = [url host];
   464 			NSString	*ircHost = [url host];
   471 			NSString	*name;
   465 			NSString	*name;
   472 			if (user && [user length]) {
   466 			if (user && [user length]) {
   473 				//jabber://tekjew@jabber.org
   467 				//jabber://tekjew@jabber.org
   474 				//msn://jdoe@hotmail.com
       
   475 				name = [NSString stringWithFormat:@"%@@%@",[url user],[url host]];
   468 				name = [NSString stringWithFormat:@"%@@%@",[url user],[url host]];
   476 			} else {
   469 			} else {
   477 				//aim://tekjew
   470 				//aim://tekjew
   478 				name = ircHost;
   471 				name = ircHost;
   479 			}
   472 			}