[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl-Toolbox] Internet Config



Some proposed additions to IC.pm.  Any problems with this?

There is also a problem in IC with saving new mappings, IIRC.  I might
look into that at some point, but I just happened to have this here.

Better names for GetICHelper wanted.  GetURL seems fine to me since it is a pretty much globally accepted name now.  I thought about making GetICHelper a tied hash, but I didn't want to provide an object or reference, and I don't think a tied hash can return a list, or even recognize wantarray.

Is this the right place for this?  Would toolbox or porters be better?

(Matthias cc:d on the offchance he is not subscribed yet. :)

*** Bird:src:freebie cvs:MacPerl:perl:ext:Mac:InternetConfig:InternetConfig.pm	Thu Feb 25 12:29:43 1999
--- Bird:src:Pudge:pudgeprogs:perl:site_specific:Mac:InternetConfig.pm	Thu Feb 25 12:37:13 1999
***************
*** 130,136 ****
  		icNoPerm
  		icReadOnlyPerm
  		icReadWritePerm
! 	);
  	@EXPORT_OK = qw(
  		$ICInstance
  	);
--- 130,138 ----
  		icNoPerm
  		icReadOnlyPerm
  		icReadWritePerm
! 		GetURL
! 		GetICHelper
! );
  	@EXPORT_OK = qw(
  		$ICInstance
  	);
***************
*** 458,464 ****
  sub DESTROY {
  	my($my) = @_;
  	
! 	DisposeHandle($my->{entries});
  }
  
  sub FETCH {
--- 460,466 ----
  sub DESTROY {
  	my($my) = @_;
  	
! 	DisposeHandle($my->{entries}) if $my->{entries};
  }
  
  sub FETCH {
***************
*** 731,736 ****
--- 733,739 ----
  =back
  
  =cut
+ 
  $ICInstance = ICStart();
  
  tie %RawInternetConfig, q(Mac::InternetConfig::_Raw);
***************
*** 739,745 ****
--- 742,772 ----
  
  =include InternetConfig.xs
  
+ =item GetURL URL
+ 
+ Launch helper app with URL.  Returns undef on error.
+ 
+ =item GetICHelper PROTOCOL
+ 
+ Return list of creator ID and name for helper app assigned
+ to PROTOCOL.  Returns only creator ID in scalar context.
+ Returns undef on error.
+ 
  =cut
+ 
+ sub GetURL {
+     my $url = shift or return;
+ 	ICGeneralFindConfigFile($ICInstance);
+     ICLaunchURL($ICInstance, 0, $url);
+ }
+ 
+ sub GetICHelper {
+     my $proto    = shift or return;
+     my $helper   = $InternetConfig{kICHelper() . $proto} or return;
+     my $app_id   = substr($helper, 0, 4);
+     my $app_name = substr($helper, 5, ord(substr($helper, 4, 1)));
+     return wantarray ? ($app_id, $app_name) : $app_id;
+ }

-- 
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-toolbox-request@macperl.org