Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) Loose

 

Loose is a tool to redirect any email adress name to the limited number of email addresses an email host has. In its current demonstrational form, the company 'frameless.com' is used with four virtual email recipients.

 

 

 

 

Download

 

 

 

 

 

 

Older downloads

 

Technical facts

 

Application type(s)

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: ./ToolLoose/ToolLoose.pro

 

QT       += core
QT       -= gui
LIBS += -lwt -lwthttp -lboost_signals

CONFIG   += console
CONFIG   -= app_bundle
TEMPLATE = app

SOURCES += \
    wtlooseapplication.cpp \
    wtmain.cpp \
    wtloosemaindialog.cpp

HEADERS += \
    wtlooseapplication.h \
    wtloosemaindialog.h

 

 

 

 

 

./ToolLoose/wtlooseapplication.h

 

//---------------------------------------------------------------------------
/*
Loose, reduce an emailaddress to an unknown limited set
Copyright (C) 2010-2013 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolLoose.htm
//---------------------------------------------------------------------------
#ifndef WTLOOSEAPPLICATION_H
#define WTLOOSEAPPLICATION_H

#include <Wt/WApplication>

struct WtLooseMaindialog;

struct WtLooseApplication : public Wt::WApplication
{
  WtLooseApplication(const Wt::WEnvironment& env);
  private:
  WtLooseMaindialog * const m_widget;
};

#endif // WTLOOSEAPPLICATION_H

 

 

 

 

 

./ToolLoose/wtlooseapplication.cpp

 

//---------------------------------------------------------------------------
/*
Loose, reduce an emailaddress to an unknown limited set
Copyright (C) 2010-2013 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolLoose.htm
//---------------------------------------------------------------------------
#include "wtlooseapplication.h"
#include "wtloosemaindialog.h"

WtLooseApplication::WtLooseApplication(const Wt::WEnvironment& env)
  : Wt::WApplication(env),
    m_widget(new WtLooseMaindialog)
{
  this->setTitle("Loose (C) 2010 Richel Bilderbeek");
  root()->addWidget(m_widget);
}

 

 

 

 

 

./ToolLoose/wtloosemaindialog.h

 

//---------------------------------------------------------------------------
/*
Loose, reduce an emailaddress to an unknown limited set
Copyright (C) 2010-2013 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolLoose.htm
//---------------------------------------------------------------------------
#ifndef WTLOOSEMAINDIALOG_H
#define WTLOOSEMAINDIALOG_H

#include <string>
#include <vector>

#include <Wt/WContainerWidget>

namespace Wt
{
  struct WImage;
};

struct WtLooseMaindialog : public Wt::WContainerWidget
{
  static const std::vector<std::string> GetAbout();
  static const std::vector<std::string> GetLicence();
  static const std::string GetVersion();
  static const std::vector<std::string> GetVersionHistory();
  static const std::vector<std::string> GetWhatsNew();
  WtLooseMaindialog();
  private:
  Wt::WPushButton * const m_button_about;
  Wt::WPushButton * const m_button_check;
  Wt::WPushButton * const m_button_licence;
  Wt::WPushButton * const m_button_whatsnew;
  Wt::WContainerWidget * const m_container;
  Wt::WLineEdit * const m_edit;
  Wt::WImage * const m_image;
  Wt::WText * const m_result;
  Wt::WScrollArea * const m_scroll_area;
  Wt::WTextArea * const m_text_area;
  void onAboutClick();
  void onCheckClick();
  void onLicenceClick();
  void onWhatsNewClick();
};

int StringToMagicInt(const std::string& s);

#endif // WTLOOSEMAINDIALOG_H

 

 

 

 

 

./ToolLoose/wtloosemaindialog.cpp

 

//---------------------------------------------------------------------------
/*
Loose, reduce an emailaddress to an unknown limited set
Copyright (C) 2010-2013 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolLoose.htm
//---------------------------------------------------------------------------
#include <boost/foreach.hpp>

#include <Wt/WBreak>
#include <Wt/WContainerWidget>
#include <Wt/WImage>
#include <Wt/WLineEdit>
#include <Wt/WPushButton>
#include <Wt/WScrollArea>
#include <Wt/WText>
#include <Wt/WTextArea>

#include "wtloosemaindialog.h"

WtLooseMaindialog::WtLooseMaindialog()
  : m_button_about(new Wt::WPushButton),
    m_button_check(new Wt::WPushButton),
    m_button_licence(new Wt::WPushButton),
    m_button_whatsnew(new Wt::WPushButton),
    m_container(new Wt::WContainerWidget),
    m_edit(new Wt::WLineEdit),
    m_image(new Wt::WImage),
    m_result(new Wt::WText),
    m_scroll_area(new Wt::WScrollArea(this)),
    m_text_area(new Wt::WTextArea)
{
  m_container->addWidget(new Wt::WText("To which email adress would you like to mail?"));
  m_container->addWidget(new Wt::WBreak());
  m_container->addWidget(m_edit);
  m_container->addWidget(new Wt::WText("@frameless.com"));
  m_container->addWidget(m_button_check);
  m_container->addWidget(m_button_about);
  m_container->addWidget(m_button_licence);
  m_container->addWidget(m_button_whatsnew);
  m_container->addWidget(new Wt::WBreak());
  m_container->addWidget(m_result);
  m_container->addWidget(new Wt::WBreak());
  m_container->addWidget(m_image);
  m_container->addWidget(new Wt::WBreak());
  m_container->addWidget(m_text_area);

  m_scroll_area->setWidget(m_container);

  m_button_about->setText("About");
  m_button_check->setText("Check");
  m_button_licence->setText("Licence");
  m_button_whatsnew->setText("What's new?");
  m_edit->setText("any_name");
  m_edit->setFocus();
  m_image->setMaximumSize(200,200);
  m_result->setText("This would result in an email to this person:");
  m_result->hide();
  m_text_area->hide();
  m_text_area->setMinimumSize(800,256);

  m_button_about->clicked().connect(this, &WtLooseMaindialog::onAboutClick);
  m_button_check->clicked().connect(this, &WtLooseMaindialog::onCheckClick);
  m_button_licence->clicked().connect(this, &WtLooseMaindialog::onLicenceClick);
  m_button_whatsnew->clicked().connect(this, &WtLooseMaindialog::onWhatsNewClick);

}

const std::vector<std::string> WtLooseMaindialog::GetAbout()
{
  std::vector<std::string> v;
  v.push_back("Loose, tool to redirect to any email adress");
  v.push_back("Version " + GetVersion());
  v.push_back("Copyright (C) 2010-2013 Richel Bilderbeek");
  v.push_back("");
  v.push_back("Programmed by Richel Bilderbeek");
  v.push_back("on the 25th of May 2013");
  v.push_back("");
  v.push_back("From http://www.richelbilderbeek.nl/ToolLoose.htm");
  v.push_back("Licenced under GPL 3.0");
  return v;
}

const std::vector<std::string> WtLooseMaindialog::GetLicence()
{
  std::vector<std::string> v;
  v.push_back("Loose, reduce an emailaddress to an unknown limited set");
  v.push_back("Copyright (C) 2007  Richel Bilderbeek");
  v.push_back("");
  v.push_back("This program is free software: you can redistribute it and/or modify");
  v.push_back("it under the terms of the GNU General Public License as published by");
  v.push_back("the Free Software Foundation, either version 3 of the License, or");
  v.push_back("(at your option) any later version.");
  v.push_back("");
  v.push_back("This program is distributed in the hope that it will be useful,");
  v.push_back("but WITHOUT ANY WARRANTY; without even the implied warranty of");
  v.push_back("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the");
  v.push_back("GNU General Public License for more details.");
  v.push_back("\n");
  v.push_back("You should have received a copy of the GNU General Public License");
  v.push_back("along with this program.  If not, see <http://www.gnu.org/licenses/>.");
  return v;
}

const std::string WtLooseMaindialog::GetVersion()
{
  return "2.1";
}

const std::vector<std::string> WtLooseMaindialog::GetVersionHistory()
{
  std::vector<std::string> v;
  v.push_back("YYYY-MM-DD: version X.Y: [description]");
  v.push_back("2010-12-03: version 1.0: initial version");
  v.push_back("2010-12-21: version 1.1: seperated WWidget from WApplication");
  v.push_back("2010-12-24: version 2.0: added 'Check' and 'What's New' buttons");
  v.push_back("2013-05-25: version 2.1: conformized naming towards ProjectRichelBilderbeek");
  return v;
}

void WtLooseMaindialog::onAboutClick()
{
  m_result->hide();

  const std::vector<std::string> v = GetAbout();
  std::string s;
  BOOST_FOREACH(const std::string& line,v)
  {
    s += line + '\n';
  }
  m_text_area->setText(s);

  m_text_area->show();
  m_image->setImageRef("R.png");
}

void WtLooseMaindialog::onCheckClick()
{
  m_text_area->hide();
  m_result->show();

  const int n_photos = 4;
  const int photo_index
    = (StringToMagicInt(m_edit->text().toUTF8())
    % n_photos)
    + 1; //Humans start counting from 1
  m_image->setImageRef(
    "RichelBilderbeek"
    + boost::lexical_cast<std::string>(photo_index)
    + ".jpg");
  m_image->setAlternateText(
    "Richel Bilderbeek "
    + boost::lexical_cast<std::string>(photo_index));
  m_image->setToolTip(
    "Richel Bilderbeek "
    + boost::lexical_cast<std::string>(photo_index));
}

void WtLooseMaindialog::onLicenceClick()
{
  m_result->hide();

  const std::vector<std::string> v = GetLicence();
  std::string s;
  BOOST_FOREACH(const std::string& line,v)
  {
    s += line + '\n';
  }
  m_text_area->setText(s);


  m_text_area->show();
  m_image->setImageRef("R.png");
}

void WtLooseMaindialog::onWhatsNewClick()
{
  m_result->hide();

  const std::vector<std::string> v = GetVersionHistory();
  std::string s;
  BOOST_FOREACH(const std::string& line,v)
  {
    s += line + '\n';
  }
  m_text_area->setText(s);


  m_text_area->show();
  m_image->setImageRef("R.png");
}

int StringToMagicInt(const std::string& s)
{
  int i = 0;
  BOOST_FOREACH(const char& c,s)
  {
    i+=static_cast<int>(c);
  }
  return i;
}

 

 

 

 

 

./ToolLoose/wtmain.cpp

 

//---------------------------------------------------------------------------
/*
Loose, reduce an emailaddress to an unknown limited set
Copyright (C) 2010-2013 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolLoose.htm
//---------------------------------------------------------------------------
#include <Wt/WApplication>

#include "wtlooseapplication.h"

Wt::WApplication * createApplication(const Wt::WEnvironment& env)
{
  return new WtLooseApplication(env);
}

int main(int argc, char **argv)
{
  return WRun(argc, argv, &createApplication);
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml