926 |
} |
} |
927 |
} # manakai_set_read_only |
} # manakai_set_read_only |
928 |
|
|
929 |
|
sub set_user_data ($$$;$) { |
930 |
|
my ($self, $key, $data, $handler) = @_; |
931 |
|
|
932 |
|
my $v = ($$self->{user_data} ||= {}); |
933 |
|
my $r = $v->{$key}->[0]; |
934 |
|
|
935 |
|
if (defined $data) { |
936 |
|
$v->{$key} = [$data, $handler]; |
937 |
|
|
938 |
|
if (defined $handler) { |
939 |
|
$$self->{manakai_onunload} = sub { |
940 |
|
my $node = $_[0]; |
941 |
|
my $uds = $$node->{user_data}; |
942 |
|
for my $key (keys %$uds) { |
943 |
|
if (defined $uds->{$key}->[1]) { |
944 |
|
$uds->{$key}->[1]->(3, $key, $uds->{$key}->[0]); # NODE_DELETED |
945 |
|
} |
946 |
|
} |
947 |
|
}; |
948 |
|
} |
949 |
|
} else { |
950 |
|
delete $v->{$key}; |
951 |
|
} |
952 |
|
return $r; |
953 |
|
} # set_user_data |
954 |
|
|
955 |
package Message::IF::Node; |
package Message::IF::Node; |
956 |
|
|
957 |
=head1 LICENSE |
=head1 LICENSE |