]> git.pld-linux.org Git - packages/asa.git/blame - asa-svn-26-05-2007.patch
- drop obsolete and outdated manual inclusion of rpm macros
[packages/asa.git] / asa-svn-26-05-2007.patch
CommitLineData
0c5fa515 1diff -ruN asa-0.1.7/ApaSMSAgent.pl asa-svn-26-05-2007/ApaSMSAgent.pl
2--- asa-0.1.7/ApaSMSAgent.pl 2005-04-22 12:23:56.000000000 +0200
3+++ asa-svn-26-05-2007/ApaSMSAgent.pl 2007-05-26 09:24:06.000000000 +0200
4@@ -58,7 +58,7 @@
5 };
6
7 my $STD_MSG="Hello! I'm ApaSMSAgent ".VERSION."\n".
8- "Add contacts like +48xxxxxxxxx@".$config{service_name}." to your roster to send them SMS messages.\n".
9+ "Add contacts like +xxxxxxxxxxx@".$config{service_name}." to your roster to send them SMS messages.\n".
10 "Browse ".$config{service_name}." in your service browser to see available plugins and change their options or register if needed.\n".
11 "Available plugins:";
12 foreach my $p (keys %plugins) {
13@@ -303,8 +303,8 @@
14 } elsif ($type eq 'set') {
15 my $nr=$query_o->GetPrompt();
16 # FIXME needs work:
17- if ($nr=~/[0-9]{11,11}/) {
18- $nr=~s/^.*([0-9]{11,11}).*$/$1/;
19+ if ($nr=~/[0-9]{11,}/) {
20+ $nr=~s/^.*?([0-9]{11,}).*?$/$1/;
21 } elsif ($nr=~/[0-9]{9,9}/) {
22 $nr=~s/^.*([0-9]{9,9}).*$/48$1/;
23 } else {
24@@ -405,9 +405,21 @@
25 $message->SetBody($b);
26 $message->SetType($message_o->GetType());
27 $Connection->Send($message);
28+ } elsif ($body =~ /^\/stats$/i) {
29+ log3("stats from admin $base_from");
30+ my $b="Users #".(keys %numbers);
31+ my $numbers_count = 0;
32+ foreach my $user (keys %numbers) {
33+ $numbers_count += keys %{$numbers{$user}};
34+ };
35+ $b .= ", numbers #".$numbers_count;
36+ $message->SetBody($b);
37+ $message->SetType($message_o->GetType());
38+ $Connection->Send($message);
39 } elsif ($body =~ /^\/help$/i) {
40 log3("help from admin $base_from");
41 $message->SetBody("/wall or /motd - wall message\n".
42+ "/stats - print basic statistic info\n".
43 "/DUMPPLUGINS - dump plugins hash\n".
44 "/DUMPCONFIG - dump config hash\n".
45 # "/dumpnumbers - dump numbers hash\n".
46@@ -480,7 +492,7 @@
47 };
48 };
49 } elsif ($to =~ /@/) { # someting with @ :P
50- if ($to =~ /^\+[0-9]{11}\@/) { # generic nr, good nr
51+ if ($to =~ /^\+(48[0-9]{9}|[0-9]{11,})\@/) { # generic nr, good nr
52 my $nr=$to; $nr=~s/@.+$//;
53 if ($type eq 'subscribe') {
54 $presence->SetType('subscribe'); # ask him for auth, we need to maintain his list of numbers
55diff -ruN asa-0.1.7/config.xml asa-svn-26-05-2007/config.xml
56--- asa-0.1.7/config.xml 2005-01-14 21:18:13.000000000 +0100
57+++ asa-svn-26-05-2007/config.xml 2007-05-26 09:24:23.000000000 +0200
58@@ -28,23 +28,23 @@
59 <load>
60 <plugin>MiastoPlusa</plugin>
61 <plugin>WwwPlusa</plugin>
62- <plugin>IdeaMbox</plugin>
63- <plugin>EraOmnix_Podstawowa</plugin>
64- <plugin>EraOmnix_Platna</plugin>
65+ <plugin>OrangeMbox</plugin>
66+ <plugin>EraOmnix_Sponsorowana</plugin>
67+ <plugin>EraOmnix_Multimedialna</plugin>
68 </load>
69 <!-- plugins' own options and settings -->
70 <plugins>
71 <MiastoPlusa>
72 <accounts_file>./storage/accounts-MiastoPlusa.mldbm</accounts_file>
73 </MiastoPlusa>
74- <IdeaMbox>
75- <accounts_file>./storage/accounts-IdeaMbox.mldbm</accounts_file>
76- </IdeaMbox>
77- <EraOmnix_Podstawowa>
78- <accounts_file>./storage/accounts-EraOmnix_Podstawowa.mldbm</accounts_file>
79- </EraOmnix_Podstawowa>
80- <EraOmnix_Platna>
81- <accounts_file>./storage/accounts-EraOmnix_Platna.mldbm</accounts_file>
82- </EraOmnix_Platna>
83+ <OrangeMbox>
84+ <accounts_file>./storage/accounts-OrangeMbox.mldbm</accounts_file>
85+ </OrangeMbox>
86+ <EraOmnix_Sponsorowana>
87+ <accounts_file>./storage/accounts-EraOmnix_Sponsorowana.mldbm</accounts_file>
88+ </EraOmnix_Sponsorowana>
89+ <EraOmnix_Multimedialna>
90+ <accounts_file>./storage/accounts-EraOmnix_Multimedialna.mldbm</accounts_file>
91+ </EraOmnix_Multimedialna>
92 </plugins>
93 </config>
94diff -ruN asa-0.1.7/plugins/EraOmnix_Multimedialna.pl asa-svn-26-05-2007/plugins/EraOmnix_Multimedialna.pl
95--- asa-0.1.7/plugins/EraOmnix_Multimedialna.pl 1970-01-01 01:00:00.000000000 +0100
96+++ asa-svn-26-05-2007/plugins/EraOmnix_Multimedialna.pl 2007-05-26 09:25:13.000000000 +0200
97@@ -0,0 +1,181 @@
98+use strict;
99+use LWP::UserAgent;
100+use HTTP::Request::Common qw(GET POST);
101+use HTTP::Response;
102+use Unicode::Lite;
103+
104+my $PLUGIN_NAME = "EraOmnix_Multimedialna";
105+my $PLUGIN_VERSION = "0.3-20051002-kg";
106+my $DEFAULT_PRIO = 5;
107+my $DEST_NUMBERS_REGEXP = '^\+[0-9]+'; # needed linke this in // good numberz? any, they say
108+
109+use vars qw ( %EraOmnix_Mult_accounts );
110+
111+# RULES:
112+# 1. ALWAYS, ALWAYS, ALWAYS create new presence/message/iq
113+# 2. Create handlers, plugin is named ser.vi.ce/Plugin
114+# 3. Provide ALL info into %plugin_data
115+
116+RegisterEvent('iq','^'.$config{service_name}."/".$PLUGIN_NAME.'$',\&EraOmnix_Mult_InIQ); # for registration
117+RegisterEvent('pre_connect','.+',\&EraOmnix_Mult_PreConn); # for loading some data ;)
118+
119+$plugin_data{$PLUGIN_NAME}->{inmessage_h}=\&EraOmnix_Mult_InMessage;
120+$plugin_data{$PLUGIN_NAME}->{will_take_h}=\&EraOmnix_Mult_WillTake;
121+$plugin_data{$PLUGIN_NAME}->{default_prio}=$DEFAULT_PRIO;
122+$plugin_data{$PLUGIN_NAME}->{version}=$PLUGIN_VERSION;
123+$plugin_data{$PLUGIN_NAME}->{needs_reg}=1;
124+
125+sub EraOmnix_Mult_WillTake {
126+ my $from=shift;
127+ my $to_nr=shift; # if not provided, it means it asks for the service, w/o number served by it
128+ return (($to_nr?($to_nr =~ /$DEST_NUMBERS_REGEXP/):1)&&(exists($EraOmnix_Mult_accounts{$from})));
129+};
130+
131+sub EraOmnix_Mult_PreConn {
132+# %EraOmnix_Mult_accounts=%{LoadXMLHash('accounts',$config{plugins}->{$PLUGIN_NAME}->{accounts_file},$PLUGIN_NAME)};
133+ my $t=tie(%EraOmnix_Mult_accounts,"MLDBM::Sync",$config{plugins}->{$PLUGIN_NAME}->{accounts_file},O_CREAT|O_RDWR,0600);
134+ log2($PLUGIN_NAME.": Ready.");
135+};
136+
137+sub EraOmnix_Mult_InIQ {
138+ my $iq_o=shift;
139+ my $xmlns=shift;
140+ my $query_o=$iq_o->GetQuery();
141+ my $type=$iq_o->GetType();
142+ my $from=$iq_o->GetFrom(); my $to=$iq_o->GetTo();
143+ my $iq=new Net::Jabber::IQ;
144+ $iq->SetFrom($to); $iq->SetTo($from); $iq->SetID($iq_o->GetID);
145+ my $query=$iq->NewQuery($xmlns);
146+
147+ if ($xmlns eq 'jabber:iq:register') {
148+ my $base_from=$from; $base_from=~s/\/.+$//g if ($base_from =~ /\//);
149+ my $account=$EraOmnix_Mult_accounts{$base_from};
150+ if ($type eq 'get') {
151+ $iq->SetType('result');
152+ $query->SetInstructions('Send a message to: +48TELNUMBER@'.$config{service_name}." to send an SMS.\n".
153+ "You can add a contact like this to your roster.\n\n".
154+ "Provide your Username and Password to ".$PLUGIN_NAME." gateway.\n".
155+ "See http://www.eraomnix.pl/pl/between-us/send-sms-mms for info.\n\n".
156+ "Note: x:data compilant client allows setting more options.");
157+ $query->SetUsername( ($account?$account->{username}:'') );
158+ $query->SetPassword('');
159+ # x:data ...
160+ my $xd=( (Net::Jabber->VERSION>1.30) ? new Net::Jabber::Stanza("x") : new Net::Jabber::X );
161+ $xd->SetXMLNS('jabber:x:data');
162+ $xd->SetData(instructions=>'Send a message to: +48TELNUMBER@'.$config{service_name}." to send an SMS.\n".
163+ "You can add a contact like this to your roster.\n".
164+ "Provide your Username and Password to ".$PLUGIN_NAME." gateway.\n".
165+ "See http://www.eraomnix.pl/pl/between-us/send-sms-mms for info.\n".
166+ "You can configure additional options too. When changing options, remember to provide ".
167+ "your password!",
168+ title=>"$PLUGIN_NAME Registration",
169+ type=>'form');
170+ $xd->AddField(type=>'text-single',var=>'username',label=>'User name',
171+ value=>($account?$account->{username}:''));
172+ $xd->AddField(type=>'text-private',var=>'password',label=>'Password (!) ');
173+ $xd->AddField(type=>'boolean',var=>'mms',label=>'MMS',
174+ value=>($account->{mms}?$account->{mms}:0));
175+ $query->AddX($xd);
176+ # ... x:data
177+ $Connection->Send($iq);
178+ } elsif ($type eq 'set') {
179+ # x:data ...
180+ my @xd=$query_o->GetX('jabber:x:data'); my %f;
181+ if ($#xd>-1) {
182+ foreach my $x ($xd[0]->GetFields()) { $f{$x->GetVar()}=$x->GetValue(); };
183+ } else {
184+ $f{username}=$query_o->GetUsername(); $f{password}=$query_o->GetPassword();
185+ $f{mms}=0;
186+ };
187+ # ... x:data
188+ if (($f{username} eq '')&&($f{password} eq '')) {
189+ SendPluginPresencesToUser($PLUGIN_NAME,'unavailable',$from);
190+ delete $EraOmnix_Mult_accounts{$base_from};
191+ } else {
192+ for my $i (qw(username password mms)) { $account->{$i}=$f{$i}; };
193+ $EraOmnix_Mult_accounts{$base_from}=$account;
194+ SendPluginPresencesToUser($PLUGIN_NAME,'available',$from);
195+ PushAgentToUsersRoster($from); # important in any plugin which needs registration!
196+ };
197+# SaveXMLHash(\%EraOmnix_Mult_accounts,'accounts',$config{plugins}->{$PLUGIN_NAME}->{accounts_file},$PLUGIN_NAME);
198+ $iq->SetType('result');
199+ $Connection->Send($iq);
200+ };
201+ };
202+};
203+
204+my %EraOmnix_Mult_errmsgs=(
205