Changeset 25729b2
- Timestamp:
- Jan 8, 2007, 4:17:55 PM (18 years ago)
- Branches:
- master, barnowl_perlaim, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 723f464
- Parents:
- 6beac73
- git-author:
- Nelson Elhage <nelhage@mit.edu> (01/08/07 15:55:09)
- git-committer:
- Nelson Elhage <nelhage@mit.edu> (01/08/07 16:17:55)
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
functions.c
r451becb r25729b2 2835 2835 2836 2836 /* narrow personal and login messages to the sender or recip as appropriate */ 2837 if (owl_message_is_ personal(m) || owl_message_is_loginout(m)) {2838 if (owl_message_is_ type_zephyr(m)) {2837 if (owl_message_is_type_zephyr(m)) { 2838 if (owl_message_is_personal(m) || owl_message_is_loginout(m)) { 2839 2839 if (owl_message_is_direction_in(m)) { 2840 2840 zperson=short_zuser(owl_message_get_sender(m)); 2841 2841 } else { 2842 2842 zperson=short_zuser(owl_message_get_recipient(m)); 2843 2843 } 2844 2844 filtname=owl_function_zuserfilt(zperson); … … 2846 2846 return(filtname); 2847 2847 } 2848 return(NULL); 2849 } 2850 2851 /* narrow class MESSAGE, instance foo, recip * messages to class, inst */ 2852 if (!strcasecmp(owl_message_get_class(m), "message") && !owl_message_is_personal(m)) { 2853 filtname=owl_function_classinstfilt(owl_message_get_class(m), owl_message_get_instance(m)); 2848 2849 /* narrow class MESSAGE, instance foo, recip * messages to class, inst */ 2850 if (!strcasecmp(owl_message_get_class(m), "message") && !owl_message_is_personal(m)) { 2851 filtname=owl_function_classinstfilt(owl_message_get_class(m), owl_message_get_instance(m)); 2852 return(filtname); 2853 } 2854 2855 /* otherwise narrow to the class */ 2856 if (type==0) { 2857 filtname=owl_function_classinstfilt(owl_message_get_class(m), NULL); 2858 } else if (type==1) { 2859 filtname=owl_function_classinstfilt(owl_message_get_class(m), owl_message_get_instance(m)); 2860 } 2854 2861 return(filtname); 2855 2862 } 2856 2863 2857 /* otherwise narrow to the class */ 2858 if (type==0) { 2859 filtname=owl_function_classinstfilt(owl_message_get_class(m), NULL); 2860 } else if (type==1) { 2861 filtname=owl_function_classinstfilt(owl_message_get_class(m), owl_message_get_instance(m)); 2862 } 2863 return(filtname); 2864 /* pass it off to perl */ 2865 char *argv[1]; 2866 if(type) { 2867 argv[0] = "-i"; 2868 }; 2869 return owl_perlconfig_message_call_method(m, "smartfilter", type ? 1 : 0, argv); 2864 2870 } 2865 2871 -
perl/modules/jabber.pl
r9667006 r25729b2 1156 1156 } 1157 1157 1158 ##################################################################### 1159 ##################################################################### 1160 1161 package owl::Message::Jabber; 1162 1163 our @ISA = qw( owl::Message ); 1164 1165 sub jtype { shift->{jtype} }; 1166 sub from { shift->{from} }; 1167 sub to { shift->{to} }; 1168 1169 sub smartfilter { 1170 my $self = shift; 1171 my $inst = shift; 1172 1173 if($self->jtype eq 'chat') { 1174 my ($user, $filter, $ftext); 1175 if($self->direction eq 'in') { 1176 $user = $self->from; 1177 } else { 1178 $user = $self->to; 1179 } 1180 $user = Net::Jabber::JID->new($user)->GetJID($inst ? 'full' : 'base'); 1181 $filter = "jabber-user-$user"; 1182 $ftext = qq{type ^jabber\$ and ( ( direction ^in\$ and from ^$user ) } . 1183 qq{or ( direction ^out\$ and to ^$user ) ) }; 1184 owl::filter("$filter $ftext"); 1185 return $filter; 1186 } 1187 } 1188 1158 1189 1; -
perlconfig.c
ra55abb3 r25729b2 161 161 return out; 162 162 } 163 164 165 /* Calls a method on a perl object representing a message. 166 If the return value is non-null, the caller must free it. 167 */ 168 char * owl_perlconfig_message_call_method(owl_message *m, char *method, int argc, char ** argv) 169 { 170 dSP; 171 unsigned int count, len, i; 172 SV *msgref, *srv; 173 char *out, *preout; 174 175 msgref = owl_perlconfig_message2hashref(m); 176 177 ENTER; 178 SAVETMPS; 179 180 PUSHMARK(SP); 181 XPUSHs(msgref); 182 for(i=0;i<argc;i++) { 183 XPUSHs(sv_2mortal(newSVpv(argv[i], 0))); 184 } 185 PUTBACK; 186 187 count = call_method(method, G_SCALAR|G_KEEPERR|G_EVAL); 188 189 SPAGAIN; 190 191 if(count != 1) { 192 fprintf(stderr, "perl returned wrong count %d\n", count); 193 abort(); 194 } 195 196 if (SvTRUE(ERRSV)) { 197 STRLEN n_a; 198 owl_function_error("Error: '%s'", SvPV(ERRSV, n_a)); 199 /* and clear the error */ 200 sv_setsv (ERRSV, &PL_sv_undef); 201 } 202 203 srv = POPs; 204 205 if (srv) { 206 preout=SvPV(srv, len); 207 out = owl_malloc(strlen(preout)+1); 208 strncpy(out, preout, len); 209 out[len] = '\0'; 210 } else { 211 out = NULL; 212 } 213 214 PUTBACK; 215 FREETMPS; 216 LEAVE; 217 218 return out; 219 } 220 163 221 164 222 char *owl_perlconfig_readconfig(void) -
perlwrap.pm
r23be736 r25729b2 187 187 } 188 188 189 sub smartfilter { 190 die("smartfilter not supported for this message"); 191 } 192 189 193 ##################################################################### 190 194 ##################################################################### … … 274 278 ##################################################################### 275 279 ##################################################################### 276 277 package owl::Message::Jabber;278 279 @ISA = qw( owl::Message );280 281 #####################################################################282 #####################################################################283 280 ################################################################################ 284 281 package owl; … … 317 314 { 318 315 my $hook = shift; 319 use Data::Dumper;320 316 my @args = @_; 321 317 return join("\n", map {$_->(@args)} @$hook);
Note: See TracChangeset
for help on using the changeset viewer.