diff options
author | Florent Le Coz <louiz@louiz.org> | 2013-11-10 20:47:11 +0100 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2013-11-10 20:47:11 +0100 |
commit | f0d9273da61ce154dbe460cf58c98de851d30615 (patch) | |
tree | bbca8a7adca39ced153a7f4d04d3964692bd4f5d /src/main.cpp | |
parent | 10d528717723a72dd3240c634980a461cf9fa2df (diff) | |
download | biboumi-f0d9273da61ce154dbe460cf58c98de851d30615.tar.gz biboumi-f0d9273da61ce154dbe460cf58c98de851d30615.tar.bz2 biboumi-f0d9273da61ce154dbe460cf58c98de851d30615.tar.xz biboumi-f0d9273da61ce154dbe460cf58c98de851d30615.zip |
Add a Config module, and use it to get the password from a file
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/main.cpp b/src/main.cpp index b7fa01e..80c8436 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,13 +1,32 @@ -#include <network/poller.hpp> #include <xmpp/xmpp_component.hpp> +#include <network/poller.hpp> +#include <config/config.hpp> +#include <iostream> #include <memory> -int main() +int main(int ac, char** av) { - Poller p; + if (ac > 1) + Config::filename = av[1]; + Config::file_must_exist = true; + + std::string password; + try { // The file must exist + password = Config::get("password", ""); + } + catch (const std::ios::failure& e) { + return 1; + } + if (password.empty()) + { + std::cerr << "No password provided." << std::endl; + return 1; + } std::shared_ptr<XmppComponent> xmpp_component = - std::make_shared<XmppComponent>("irc.localhost", "secret"); + std::make_shared<XmppComponent>("irc.abricot", password); + + Poller p; p.add_socket_handler(xmpp_component); xmpp_component->start(); while (p.poll()) |