5 |
|
// $Id$ |
6 |
|
|
7 |
|
#include "AwayMessage.hpp" |
8 |
+ |
#include "Matcher.hpp" |
9 |
|
|
10 |
< |
AwayMessage::operator const ext::String&() const |
10 |
> |
ext::String AwayMessage::getLink(const Buddy& buddy) const |
11 |
|
{ |
12 |
+ |
return buddy.getLink() + "#z" + stamp.getW3(); |
13 |
+ |
} |
14 |
+ |
|
15 |
+ |
ext::String AwayMessage::getTag(const Buddy& buddy) const |
16 |
+ |
{ |
17 |
+ |
Matcher matcher("^http://([a-zA-Z.\\-0-9]+)(/.*)$"); |
18 |
+ |
|
19 |
+ |
if (buddy.getLink() == matcher) |
20 |
+ |
{ |
21 |
+ |
return "tag:" + matcher[1] + "," + stamp.get8601() + ":" + matcher[2] |
22 |
+ |
+ "/z" + stamp.getW3(); |
23 |
+ |
} |
24 |
+ |
else |
25 |
+ |
{ |
26 |
+ |
cerr << Zoe::program << ": AwayMessage::getTag(" << buddy << ")\n"; |
27 |
+ |
|
28 |
+ |
exit(1); |
29 |
+ |
} |
30 |
+ |
} |
31 |
+ |
|
32 |
+ |
AwayMessage::operator ext::String() const |
33 |
+ |
{ |
34 |
+ |
std::string message(this->message); |
35 |
+ |
std::string::size_type begin(0), found; |
36 |
+ |
|
37 |
+ |
while ((found = message.find('%', begin)) != std::string::npos) |
38 |
+ |
{ |
39 |
+ |
if (message.find_first_of("ndt", found + 1) == found + 1) |
40 |
+ |
{ |
41 |
+ |
switch (message[found + 1]) |
42 |
+ |
{ |
43 |
+ |
case 'n': |
44 |
+ |
message.replace(found, 2, "Zoe"); |
45 |
+ |
|
46 |
+ |
begin = found + 3; |
47 |
+ |
|
48 |
+ |
break; |
49 |
+ |
case 'd': |
50 |
+ |
message.replace(found, 2, stamp.getDate()); |
51 |
+ |
|
52 |
+ |
begin = found + 10; |
53 |
+ |
|
54 |
+ |
break; |
55 |
+ |
case 't': |
56 |
+ |
message.replace(found, 2, stamp.getTime()); |
57 |
+ |
|
58 |
+ |
begin = found + 11; |
59 |
+ |
} |
60 |
+ |
} |
61 |
+ |
else begin = found + 1; |
62 |
+ |
} |
63 |
+ |
|
64 |
|
return message; |
65 |
|
} |