Commit 2aac599a authored by Romain Bignon's avatar Romain Bignon

param irc/buddy_icons_url to display an URL to download icon in /WHOIS (refs #156)

parent b013b4a7
......@@ -178,6 +178,16 @@ CacaImage Buddy::getIcon() const
return CacaImage(purple_buddy_icon_get_full_path(bicon));
}
string Buddy::getIconPath() const
{
assert(isValid());
PurpleBuddyIcon* bicon = purple_buddy_icons_find(buddy->account, buddy->name);//purple_buddy_get_icon(buddy);
if(!bicon)
return "";
return purple_buddy_icon_get_full_path(bicon);
}
PurpleGroup* Buddy::getPurpleGroup() const
{
assert(isValid());
......
......@@ -93,6 +93,8 @@ namespace im
*/
CacaImage getIcon() const;
string getIconPath() const;
PurpleGroup* getPurpleGroup() const;
PurpleBuddy* getPurpleBuddy() const { return buddy; }
......
......@@ -75,6 +75,8 @@ namespace im
/** Get path to user settings */
string getUserPath() const { return user_path; }
string getUsername() const { return username; }
/** Set user password */
void setPassword(const string& password);
string getPassword() const;
......
......@@ -98,6 +98,11 @@ CacaImage Buddy::getIcon() const
return im_buddy.getIcon();
}
string Buddy::getIconPath() const
{
return im_buddy.getIconPath();
}
bool Buddy::retrieveInfo() const
{
im_buddy.retrieveInfo();
......
......@@ -57,7 +57,9 @@ namespace irc
im::Buddy getBuddy() const { return im_buddy; }
/** Get icon in an coloured ASCII-art form. */
CacaImage getIcon() const;
virtual CacaImage getIcon() const;
virtual string getIconPath() const;
/** Get buddy's real name. */
virtual string getRealName() const;
......
......@@ -717,6 +717,16 @@ void IRC::m_whois(Message message)
.addArg(n->getNickname())
.addArg("libcaca and imlib2 are required to display icon"));
}
string url = conf.GetSection("irc")->GetItem("buddy_icons_url")->String();
string icon_path = n->getIconPath();
if(url != " " && !icon_path.empty())
{
icon_path = icon_path.substr(im->getUserPath().size());
user->send(Message(RPL_WHOISACTUALLY).setSender(this)
.setReceiver(user)
.addArg(n->getNickname())
.addArg("Icon URL: " + url + im->getUsername() + icon_path));
}
/* Retrieve server info about this buddy only if this is an extended
* whois. In this case, do not send a ENDOFWHOIS because this
......
......@@ -173,6 +173,7 @@ namespace irc
virtual bool isOnline() const { return true; }
virtual CacaImage getIcon() const;
virtual string getIconPath() const { return ""; }
};
}; /* namespace irc */
......
......@@ -139,6 +139,7 @@ Minbif::Minbif()
section->AddItem(new ConfigItem_string("password", "Global server password", " "));
section->AddItem(new ConfigItem_int("type", "Type of daemon", 0, 2, "0"));
section->AddItem(new ConfigItem_int("ping", "Ping frequence (s)", 0, 65535, "60"));
section->AddItem(new ConfigItem_string("buddy_icons_url", "URL to display in /WHOIS to get a buddy icon", " "));
section = section->AddSection("daemon", "Daemon information", true);
section->AddItem(new ConfigItem_ipaddr("bind", "IP address to listen on"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment