#!hs2 ############################################################################# # Script : DetectProvider.hsm # Purpose : Detect Provider to use # Time-stamp: ############################################################################# # NOTE: You have to customize the connection-, provider- and server-names # in Provider4Connection and Servers4Provider according to your needs. # Look for '@@@ customize'. ############################################################################# #!load Fritzweb_Online.hsm #!debug 1 #!initialize debug( 255, "<<< module 'DetectProvider.hsm' >>>" ) HamRequireVersion( "1.3.21.0", True ) return(0) # ------------------------------------------------------- # sub Provider4Connection($connection,*$provider) # ------------------------------------------------------- # set provider name used for $connection # ------------------------------------------------------- sub Provider4Connection($connection,*$provider) $provider = "" # @@@ customize: replace "Freenet" by a unique string which only # occurs in the connection you like to detect if (RE_Match($connection, "freenet")) # @@@ customize: replace "freenet" by any id you like # (you have to use the same id in Servers4Provider # and in Scheduler (if you use it)) $provider = "freenet" endif # @@@ customize (like above) if (RE_Match($connection, "Easysurfer")) $provider = "msn" endif if (RE_Match($connection, "Intercom")) $provider = "intercom" endif if (RE_Match($connection, "Dusnet")) $provider = "dusnet" endif if (RE_Match($connection, "NGI")) $provider = "ngi" endif if (RE_Match($connection, "EasyNet")) $provider = "easynet" endif if (RE_Match($connection, "easy.call.*city")) $provider = "easynet" endif if (RE_Match($connection, "talkline")) $provider = "talkline" endif if (RE_Match($connection, "Compuserve")) $provider = "compuserve" endif if (RE_Match($connection, "tlink")) $provider = "tlink" endif if (RE_Match($connection, "callisa")) $provider = "callisa" endif if (RE_Match($connection, "ACN")) $provider = "acn" endif if (RE_Match($connection, "Ventelo")) $provider = "ventelo" endif endsub # --------------------------------------------------------------------- # sub Servers4Provider($provider,*$fetchmail,*$sendmail,*$news) # --------------------------------------------------------------------- # set fetchmail-, sendmail- and news-servers for provider # (I call this from my Exchange function) # if you have several alternative mail/newsservers you can enter them # under different $possibility. Servers4Provider is called several times, # until all servers are equal to "" (what means: no more possibilities) # --------------------------------------------------------------------- sub Servers4Provider($provider,$possibility,*$fetchmail,*$sendmail,*$postnews,*$pullnews,*$POPvorSMTP) $fetchmail = "" $sendmail = "" $postnews = "" $pullnews = "" $POPvorSMTP = 0 # @@@ customize: use same id as for $provider in Provider4Connection if ($possibility==1) # set news server if ($provider=="lrz") # "lrz" provides news at news.lrz-muenchen.de $postnews = "news.lrz-muenchen.de,nntp" $pullnews = "news.lrz-muenchen.de,nntp" else # all other providers provide News.CIS.DFN.DE $postnews = "News.CIS.DFN.DE,nntp" $pullnews = "News.CIS.DFN.DE,nntp" endif # set mail server $fetchmail = "pop3.reallysoft.de" $sendmail = "smtp.reallysoft.de" $POPvorSMTP = 0 endif if ($possibility==2) if ($provider=="lrz") $fetchmail = "mailin.lrz-muenchen.de" $sendmail = "mailhost.lrz-muenchen.de" endif if ($provider=="freenet") $fetchmail = "pop3.freenet.de" endif if ($provider=="ngi") $fetchmail = "pop.ngi.de" $sendmail = "smtp.ngi.de" endif endif # sendmail via compuserve does not work: # if ($provider=="compuserve") # $sendmail = "" # endif return($fetchmail!="" || $sendmail!="" || $postnews!="" || $pullnews!="") endsub # ---------------------------------------------------------------------- # sub DetectProvider($go_online,$sec_to_wait,*$error,*$provider) # ---------------------------------------------------------------------- # Autodetect current connection # $go_online = 0 : do not set $provider if we are not online # $sec_to_wait : delay in seconds to wait for FritzWeb to initialize # $error : set to error message # $provider : set to provider if connection active/possible # ---------------------------------------------------------------------- sub DetectProvider($go_online,$sec_to_wait,*$error,*$provider) var($online,$connection,$trytill,$found_provider) $trytill = time + $sec_to_wait # wait some time for FritzWeb to start up $found_provider = "" $provider = "" $error = "" while ($error=="" && $found_provider=="" && time<=$trytill) FritzWebDetect($online,$connection) debug(1,"---------- online = "+$online) debug(1,"---------- connection = "+$connection) if ($connection!="") Provider4Connection($connection,$found_provider) if ($found_provider=="") $error = "No provider defined for '" + $connection + "'" endif else sleep(1500) # wait for fritzweb to startup endif endwhile if ($found_provider!="") if ($online==1 || $go_online==1) $provider = $found_provider else if ($online==0 && $go_online==0) $error = "Not online" endif endif else if ($error=="") $error = "Timeout (Fritzweb not activ)" endif endif debug(1,"---------- provider = "+$provider) debug(1,"---------- error = "+$error) endsub