Changeset - e63427c2da8a
backends/frotz/dfrotz/common/buffer.c
Show inline comments
 
@@ -15,12 +15,14 @@
 
 *
 
 * You should have received a copy of the GNU General Public License
 
 * along with this program; if not, write to the Free Software
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 
 */
 

	
 
#include <string.h>
 

	
 
#include "frotz.h"
 

	
 
extern void stream_char (zchar);
 
extern void stream_word (const zchar *);
 
extern void stream_new_line (void);
 

	
backends/frotz/dfrotz/common/input.c
Show inline comments
 
@@ -18,12 +18,13 @@
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 
 */
 

	
 
#include "frotz.h"
 

	
 
extern int save_undo (void);
 
extern int os_read_mouse (void);
 

	
 
extern zchar stream_read_key (zword, zword, bool);
 
extern zchar stream_read_input (int, zchar *, zword, zword, bool, bool);
 

	
 
extern void tokenise_line (zword, zword, zword, bool);
 

	
backends/frotz/dfrotz/common/main.c
Show inline comments
 
@@ -29,15 +29,18 @@
 
#include "frotz.h"
 

	
 
#ifndef MSDOS_16BIT
 
#define cdecl
 
#endif
 

	
 
extern void interpret (void);
 
extern void init_memory (void);
 
extern void init_undo (void);
 
extern void init_sound (void);
 
extern void init_buffer (void);
 
extern void init_process (void);
 
extern void interpret (void);
 
extern void reset_memory (void);
 

	
 
/* Story file name, id number and size */
 

	
 
char *story_name = 0;
 

	
backends/frotz/dfrotz/dumb/dumb_init.c
Show inline comments
 
@@ -61,34 +61,35 @@ While running, enter \"\\help\" to list the runtime escape sequences.\n\
 
/* A unix-like getopt, but with the names changed to avoid any problems.  */
 
static int zoptind = 1;
 
static int zoptopt = 0;
 
static char *zoptarg = NULL;
 
static int zgetopt (int argc, char *argv[], const char *options)
 
{
 
    static pos = 1;
 
    static int pos = 1;
 
    const char *p;
 
    if (zoptind >= argc || argv[zoptind][0] != '-' || argv[zoptind][1] == 0)
 
	return EOF;
 
    zoptopt = argv[zoptind][pos++];
 
    zoptarg = NULL;
 
    if (argv[zoptind][pos] == 0)
 
	{ pos = 1; zoptind++; }
 
    p = strchr (options, zoptopt);
 
    if (zoptopt == ':' || p == NULL) {
 
	fputs ("illegal option -- ", stderr);
 
	goto error;
 
    } else if (p[1] == ':')
 
    } else if (p[1] == ':') {
 
	if (zoptind >= argc) {
 
	    fputs ("option requires an argument -- ", stderr);
 
	    goto error;
 
	} else {
 
	    zoptarg = argv[zoptind];
 
	    if (pos != 1)
 
		zoptarg += pos;
 
	    pos = 1; zoptind++;
 
	}
 
    }
 
    return zoptopt;
 
error:
 
    fputc (zoptopt, stderr);
 
    fputc ('\n', stderr);
 
    return '?';
 
}/* zgetopt */
 
@@ -198,14 +199,12 @@ void os_fatal (const char *s)
 
  exit(1);
 
}
 

	
 
FILE *os_path_open(const char *name, const char *mode)
 
{
 
	FILE *fp;
 
	char buf[FILENAME_MAX + 1];
 
	char *p;
 

	
 
	/* Let's see if the file is in the currect directory */
 
	/* or if the user gave us a full path. */
 
	if ((fp = fopen(name, mode))) {
 
		return fp;
 
	}
backends/frotz/dfrotz/dumb/dumb_input.c
Show inline comments
 
@@ -245,13 +245,13 @@ static bool dumb_read_line(char *s, char *prompt, bool show_cursor,
 
	start_time = now;
 
      }
 
    } else if (!strcmp(command, "d")) {
 
      if (type != INPUT_LINE_CONTINUED)
 
	fprintf(stderr, "DUMB-FROTZ: No input to discard\n");
 
      else {
 
	dumb_discard_old_input(strlen(continued_line_chars));
 
	dumb_discard_old_input(strlen((char *) continued_line_chars));
 
	continued_line_chars[0] = '\0';
 
	type = INPUT_LINE;
 
      }
 
    } else if (!strcmp(command, "help")) {
 
      if (!do_more_prompts)
 
	fputs(runtime_usage, stdout);
 
@@ -259,13 +259,13 @@ static bool dumb_read_line(char *s, char *prompt, bool show_cursor,
 
	char *current_page, *next_page;
 
	current_page = next_page = runtime_usage;
 
	for (;;) {
 
	  int i;
 
	  for (i = 0; (i < h_screen_rows - 2) && *next_page; i++)
 
	    next_page = strchr(next_page, '\n') + 1;
 
	  printf("%.*s", next_page - current_page, current_page);
 
	  printf("%.*s", (int) (next_page - current_page), current_page);
 
	  current_page = next_page;
 
	  if (!*current_page)
 
	    break;
 
	  printf("HELP: Type <return> for more, or q <return> to stop: ");
 
	  getline_(s);
 
	  if (!strcmp(s, "q\n"))
 
@@ -366,13 +366,13 @@ zchar os_read_line (int max, zchar *buf, int timeout, int width, int continued)
 
  /* TODO: Truncate to width and max.  */
 

	
 
  /* copy to screen */
 
  dumb_display_user_input(read_line_buffer);
 

	
 
  /* copy to the buffer and save the rest for next time.  */
 
  strcat(buf, read_line_buffer);
 
  strcat((char *) buf, read_line_buffer);
 
  p = read_line_buffer + strlen(read_line_buffer) + 1;
 
  memmove(read_line_buffer, p, strlen(p) + 1);
 
    
 
  /* If there was just a newline after the terminating character,
 
   * don't save it.  */
 
  if ((read_line_buffer[0] == '\r') && (read_line_buffer[1] == '\0'))
 
@@ -382,24 +382,24 @@ zchar os_read_line (int max, zchar *buf, int timeout, int width, int continued)
 
  return terminator;
 
}
 

	
 
int os_read_file_name (char *file_name, const char *default_name, int flag)
 
{
 
  char buf[INPUT_BUFFER_SIZE], prompt[INPUT_BUFFER_SIZE];
 
  FILE *fp;
 

	
 
  sprintf(prompt, "Please enter a filename [%s]: ", default_name);
 
  dumb_read_misc_line(buf, prompt);
 
  if (strlen(buf) > MAX_FILE_NAME) {
 
    printf("Filename too long\n");
 
    return FALSE;
 
  }
 

	
 
  strcpy (file_name, buf[0] ? buf : default_name);
 

	
 
  /* Warn if overwriting a file.  */
 
//  FILE *fp;
 
//   if ((flag == FILE_SAVE || flag == FILE_SAVE_AUX || flag == FILE_RECORD)
 
//       && ((fp = fopen(file_name, "rb")) != NULL)) {
 
//     fclose (fp);
 
//     dumb_read_misc_line(buf, "Overwrite existing file? ");
 
//     return(tolower(buf[0]) == 'y');
 
//   }
 
@@ -424,7 +424,9 @@ void dumb_init_input(void)
 
    h_flags &= ~(MOUSE_FLAG | MENU_FLAG);
 
}
 

	
 
zword os_read_mouse(void)
 
{
 
	/* NOT IMPLEMENTED */
 

	
 
	return 0;
 
}
backends/frotz/dfrotz/dumb/dumb_output.c
Show inline comments
 
@@ -129,20 +129,21 @@ void os_set_text_style(int x)
 
}
 

	
 
/* put a character in the cell at the cursor and advance the cursor.  */
 
static void dumb_display_char(char c)
 
{
 
  dumb_set_cell(cursor_row, cursor_col, make_cell(current_style, c));
 
  if (++cursor_col == h_screen_cols)
 
  if (++cursor_col == h_screen_cols) {
 
    if (cursor_row == h_screen_rows - 1)
 
      cursor_col--;
 
    else {
 
      cursor_row++;
 
      cursor_col = 0;
 
    }
 
}
 
}
 

	
 
void dumb_display_user_input(char *s)
 
{
 
  /* copy to screen without marking it as a change.  */
 
  while (*s)
 
    dumb_row(cursor_row)[cursor_col++] = make_cell(0, *s++);
backends/libpurple/main.cpp
Show inline comments
 
@@ -1437,12 +1437,13 @@ static PurpleConversationUiOps conversation_ui_ops =
 

	
 
struct Dis {
 
	std::string name;
 
	std::string protocol;
 
};
 

	
 
__attribute__ ((unused))
 
static gboolean disconnectMe(void *data) {
 
	Dis *d = (Dis *) data;
 
	PurpleAccount *account = purple_accounts_find_wrapped(d->name.c_str(), d->protocol.c_str());
 
	delete d;
 

	
 
	if (account) {
 
@@ -2297,16 +2298,16 @@ int main(int argc, char **argv) {
 

	
 
	main_socket = create_socket(host.c_str(), port);
 
	purple_input_add_wrapped(main_socket, PURPLE_INPUT_READ, &transportDataReceived, NULL);
 
	purple_timeout_add_seconds_wrapped(30, pingTimeout, NULL);
 

	
 
	np = new SpectrumNetworkPlugin();
 
	bool libev = CONFIG_STRING_DEFAULTED(config, "service.eventloop", "") == "libev";
 

	
 
	GMainLoop *m_loop;
 
#ifdef WITH_LIBEVENT
 
	bool libev = CONFIG_STRING_DEFAULTED(config, "service.eventloop", "") == "libev";
 
	if (!libev) {
 
		m_loop = g_main_loop_new(NULL, FALSE);
 
	}
 
	else {
 
		event_init();
 
	}
backends/swiften/main.cpp
Show inline comments
 
@@ -204,12 +204,15 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
 
					case Swift::ClientError::CertificateUntrustedError: message = ("Certificate is not trusted"); break;
 
					case Swift::ClientError::InvalidCertificatePurposeError: message = ("Certificate cannot be used for encrypting your connection"); break;
 
					case Swift::ClientError::CertificatePathLengthExceededError: message = ("Certificate path length constraint exceeded"); break;
 
					case Swift::ClientError::InvalidCertificateSignatureError: message = ("Invalid certificate signature"); break;
 
					case Swift::ClientError::InvalidCAError: message = ("Invalid Certificate Authority"); break;
 
					case Swift::ClientError::InvalidServerIdentityError: message = ("Certificate does not match the host identity"); break;
 
					case Swift::ClientError::CertificateCardRemoved: message = ("Certificate card has been removed"); break;
 
					case Swift::ClientError::RevokedError: message = ("Certificate has been revoked"); break;
 
					case Swift::ClientError::RevocationCheckFailedError: message = ("Certificate revocation check has failed"); break;
 
				}
 
			}
 
			LOG4CXX_INFO(logger, user << ": Disconnected " << message);
 
			handleDisconnected(user, reconnect ? 0 : 3, message);
 

	
 
			SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Client> client = m_users[user];
backends/twitter/Requests/FetchFriends.cpp
Show inline comments
 
@@ -20,13 +20,13 @@ void FetchFriends::run()
 
	friends = getUsers( replyMsg );
 

	
 
	HTTPRequest req;
 
	req.init();
 
	req.setProxy(twitObj->getProxyServerIp(), twitObj->getProxyServerPort(), twitObj->getProxyUserName(), twitObj->getProxyPassword());
 

	
 
	for(int i=0 ; i<friends.size() ; i++) {
 
	for(unsigned i=0 ; i<friends.size() ; i++) {
 
		std::string img;
 
		friendAvatars.push_back("");
 
		if(req.GET(friends[i].getProfileImgURL(), img)) friendAvatars[i] = img;
 
		else {
 
			LOG4CXX_INFO(logger, "Warning: Couldn't fetch Profile Image for " << user << "'s friend " << friends[i].getScreenName());
 
		}
backends/twitter/TwitterPlugin.cpp
Show inline comments
 
@@ -210,13 +210,13 @@ void TwitterPlugin::handleMessageSendRequest(const std::string &user, const std:
 
	LOG4CXX_INFO(logger, "Received " << user << " --> " << legacyName << " - " << message);
 

	
 
	if(legacyName == adminLegacyName || legacyName == adminChatRoom)  {
 
		std::string cmd = "", data = "";
 

	
 
		/** Parsing the message - Assuming message format to be <cmd>[ ]*<data>**/
 
		int i;
 
		unsigned i;
 
		for(i=0 ; i<message.size() && message[i] != ' '; i++) cmd += message[i];
 
		while(i<message.size() && message[i] == ' ') i++;
 
		data = message.substr(i);
 
		/***********************************************************************/
 

	
 
		if(cmd == "#pin")
 
@@ -649,13 +649,13 @@ void TwitterPlugin::clearRoster(const std::string user)
 
}
 

	
 
void TwitterPlugin::populateRoster(std::string &user, std::vector<User> &friends, std::vector<std::string> &friendAvatars, Error &errMsg)
 
{
 
	if(errMsg.getMessage().length() == 0)
 
	{
 
		for(int i=0 ; i<friends.size() ; i++) {
 
		for(unsigned i=0 ; i<friends.size() ; i++) {
 
			userdb[user].buddies.insert(friends[i].getScreenName());
 
			userdb[user].buddiesInfo[friends[i].getScreenName()] = friends[i];
 
			userdb[user].buddiesImgs[friends[i].getScreenName()] = friendAvatars[i];
 

	
 
			if(userdb[user].twitterMode == MULTIPLECONTACT) {
 
				std::string lastTweet = friends[i].getLastStatus().getTweet();
 
@@ -688,13 +688,13 @@ void TwitterPlugin::populateRoster(std::string &user, std::vector<User> &friends
 

	
 
void TwitterPlugin::displayFriendlist(std::string &user, std::vector<User> &friends, std::vector<std::string> &friendAvatars, Error &errMsg)
 
{
 
	if(errMsg.getMessage().length() == 0)
 
	{
 
		std::string userlist = "\n***************USER LIST****************\n";
 
		for(int i=0 ; i < friends.size() ; i++) {
 
		for(unsigned i=0 ; i < friends.size() ; i++) {
 
			userlist += " - " + friends[i].getUserName() + " (" + friends[i].getScreenName() + ")\n";
 
		}
 
		userlist += "***************************************\n";
 
		handleMessage(user, userdb[user].twitterMode == CHATROOM ? adminChatRoom : adminLegacyName,
 
							userlist, userdb[user].twitterMode == CHATROOM ? adminNickName : "");
 
	} else {
 
@@ -711,13 +711,13 @@ void TwitterPlugin::displayFriendlist(std::string &user, std::vector<User> &frie
 
void TwitterPlugin::displayTweets(std::string &user, std::string &userRequested, std::vector<Status> &tweets , Error &errMsg)
 
{
 
	if(errMsg.getMessage().length() == 0) {
 
		std::map<std::string, int> lastTweet;
 
		std::map<std::string, int>::iterator it;
 

	
 
		for(int i = tweets.size() - 1 ; i >= 0 ; i--) {
 
		for(unsigned i = tweets.size() - 1 ; i >= 0 ; i--) {
 
			if(userdb[user].twitterMode != CHATROOM) {
 
				std::string m = " - " + tweets[i].getUserData().getScreenName() + ": " + tweets[i].getTweet() + " (MsgId: " + (tweets[i].getRetweetID().empty() ? tweets[i].getID() : tweets[i].getRetweetID()) + ")\n";
 
				handleMessage(user, adminLegacyName, m, "", "", tweets[i].getCreationTime(), true);
 

	
 
				std::string scrname = tweets[i].getUserData().getScreenName();
 
				if(lastTweet.count(scrname) == 0 || cmp(tweets[lastTweet[scrname]].getID(), tweets[i].getID()) <= 0) lastTweet[scrname] = i;
 
@@ -785,13 +785,13 @@ void TwitterPlugin::directMessageResponse(std::string &user, std::string &userna
 
	if(userdb[user].twitterMode == SINGLECONTACT) {
 

	
 
		std::string msglist = "";
 
		std::string msgID = getMostRecentDMID(user);
 
		std::string maxID = msgID;
 

	
 
		for(int i=0 ; i < messages.size() ; i++) {
 
		for(unsigned i=0 ; i < messages.size() ; i++) {
 
			if(cmp(msgID, messages[i].getID()) == -1) {
 
				msglist += " - " + messages[i].getSenderData().getScreenName() + ": " + messages[i].getMessage() + "\n";
 
				if(cmp(maxID, messages[i].getID()) == -1) maxID = messages[i].getID();
 
			}
 
		}
 

	
 
@@ -800,13 +800,13 @@ void TwitterPlugin::directMessageResponse(std::string &user, std::string &userna
 

	
 
	} else {
 

	
 
		std::string msgID = getMostRecentDMID(user);
 
		std::string maxID = msgID;
 

	
 
		for(int i=0 ; i < messages.size() ; i++) {
 
		for(unsigned i=0 ; i < messages.size() ; i++) {
 
			if(cmp(msgID, messages[i].getID()) == -1) {
 
				if(userdb[user].twitterMode == MULTIPLECONTACT)
 
					handleMessage(user, messages[i].getSenderData().getScreenName(), messages[i].getMessage(), "");
 
				else
 
					handleMessage(user, adminChatRoom, messages[i].getMessage() + " - <Direct Message>", messages[i].getSenderData().getScreenName());
 
				if(cmp(maxID, messages[i].getID()) == -1) maxID = messages[i].getID();
backends/twitter/TwitterResponseParser.cpp
Show inline comments
 
@@ -7,13 +7,13 @@
 

	
 
DEFINE_LOGGER(logger, "TwitterResponseParser")
 

	
 
static std::string tolowercase(std::string inp)
 
{
 
	std::string out = inp;
 
	for(int i=0 ; i<out.size() ; i++) out[i] = tolower(out[i]);
 
	for(unsigned i=0 ; i<out.size() ; i++) out[i] = tolower(out[i]);
 
	return out;
 
}
 

	
 
template <class T> std::string stringOf(T object) {
 
	std::ostringstream os;
 
	os << object;
 
@@ -243,13 +243,13 @@ std::vector<std::string> getIDs(std::string &json)
 
		LOG4CXX_ERROR(logger, json);
 
		return IDs;
 
	}
 

	
 
	const rapidjson::Value & ids = rootElement[TwitterReponseTypes::ids.c_str()];
 

	
 
	for(int i=0 ; i<ids.Size() ; i++) {
 
	for(unsigned i=0 ; i<ids.Size() ; i++) {
 
		IDs.push_back(stringOf( ids[i].GetInt64()) );
 
	}
 
	return IDs;
 
}
 

	
 
Error getErrorMessage(std::string &json)
include/transport/MySQLBackend.h
Show inline comments
 
@@ -124,15 +124,15 @@ class MySQLBackend : public StorageBackend
 
				Statement& operator >> (std::string& t);
 
			private:
 
				MYSQL_STMT *m_stmt;
 
				MYSQL *m_conn;
 
				std::vector<MYSQL_BIND> m_params;
 
				std::vector<MYSQL_BIND> m_results;
 
				int m_resultOffset;
 
				int m_offset;
 
				int m_error;
 
				unsigned m_resultOffset;
 
				unsigned m_offset;
 
				std::string m_string;
 
		};
 

	
 
		MYSQL m_conn;
 
		Config *m_config;
 
		std::string m_prefix;
libtransport/AdminInterface.cpp
Show inline comments
 
@@ -38,12 +38,13 @@
 
#define HAVE_SWIFTEN_3  (SWIFTEN_VERSION >= 0x030000)
 

	
 
namespace Transport {
 

	
 
DEFINE_LOGGER(logger, "AdminInterface");
 

	
 
__attribute__ ((unused))
 
static std::string getArg(const std::string &body) {
 
	std::string ret;
 
	if (body.find(" ") == std::string::npos)
 
		return ret;
 

	
 
	return body.substr(body.find(" ") + 1);
libtransport/LocalBuddy.cpp
Show inline comments
 
@@ -83,13 +83,13 @@ void LocalBuddy::setAlias(const std::string &alias) {
 
	}
 
}
 

	
 
void LocalBuddy::setGroups(const std::vector<std::string> &groups) {
 
	bool changed = m_groups.size() != groups.size();
 
	if (!changed) {
 
		for (int i = 0; i != m_groups.size(); i++) {
 
		for (unsigned i = 0; i != m_groups.size(); i++) {
 
			if (m_groups[i] != groups[i]) {
 
				changed = true;
 
				break;
 
			}
 
		}
 
	}
libtransport/MySQLBackend.cpp
Show inline comments
 
@@ -99,13 +99,13 @@ MySQLBackend::Statement::Statement(MYSQL *conn, const std::string &format, const
 
	m_stmt = mysql_stmt_init(conn);
 
	if (mysql_stmt_prepare(m_stmt, statement.c_str(), statement.size())) {
 
		LOG4CXX_ERROR(logger, statement << " " << mysql_error(conn));
 
		return;
 
	}
 

	
 
	for (int i = 0; i < format.length() && m_resultOffset == -1; i++) {
 
	for (unsigned i = 0; i < format.length() && m_resultOffset == -1; i++) {
 
		switch (format.at(i)) {
 
			case 's':
 
				m_params.resize(m_params.size() + 1);
 
				memset(&m_params.back(), 0, sizeof(MYSQL_BIND));
 

	
 
				m_params.back().buffer_type= MYSQL_TYPE_STRING;
 
@@ -135,13 +135,13 @@ MySQLBackend::Statement::Statement(MYSQL *conn, const std::string &format, const
 
			case '|':
 
				m_resultOffset = i;
 
				break;
 
		}
 
	}
 

	
 
	for (int i = m_resultOffset; i >= 0 && i < format.length(); i++) {
 
	for (unsigned i = m_resultOffset; i >= 0 && i < format.length(); i++) {
 
		switch (format.at(i)) {
 
			case 's':
 
				m_results.resize(m_results.size() + 1);
 
				memset(&m_results.back(), 0, sizeof(MYSQL_BIND));
 

	
 
				m_results.back().buffer_type= MYSQL_TYPE_STRING;
 
@@ -183,17 +183,17 @@ MySQLBackend::Statement::Statement(MYSQL *conn, const std::string &format, const
 
		}
 
	}
 
	m_resultOffset = 0;
 
}
 

	
 
MySQLBackend::Statement::~Statement() {
 
	for (int i = 0; i < m_params.size(); i++) {
 
	for (unsigned i = 0; i < m_params.size(); i++) {
 
		free(m_params[i].buffer);
 
		free(m_params[i].length);
 
	}
 
	for (int i = 0; i < m_results.size(); i++) {
 
	for (unsigned i = 0; i < m_results.size(); i++) {
 
		free(m_results[i].buffer);
 
		free(m_results[i].length);
 
	}
 
	FINALIZE_STMT(m_stmt);
 
}
 

	
libtransport/NetworkPluginServer.cpp
Show inline comments
 
@@ -1314,13 +1314,13 @@ void NetworkPluginServer::pingTimeout() {
 
	// TODO: move to separate timer, those 2 loops could be expensive
 
	// Some users are connected for weeks and they are blocking backend to be destroyed and its memory
 
	// to be freed. We are finding users who are inactive for more than "idle_reconnect_time" seconds and
 
	// reconnect them to long-running backend, where they can idle hapilly till the end of ages.
 
	time_t now = time(NULL);
 
	std::vector<User *> usersToMove;
 
	unsigned long diff = CONFIG_INT(m_config, "service.idle_reconnect_time");
 
	long diff = CONFIG_INT(m_config, "service.idle_reconnect_time");
 
	if (diff != 0) {
 
		for (std::list<Backend *>::const_iterator it = m_clients.begin(); it != m_clients.end(); it++) {
 
			// Users from long-running backends can't be moved
 
			if ((*it)->longRun) {
 
				continue;
 
			}
 
@@ -2057,13 +2057,13 @@ static void __unblock_signals ( void )
 

	
 
#endif
 

	
 
NetworkPluginServer::Backend *NetworkPluginServer::getFreeClient(bool acceptUsers, bool longRun, bool check) {
 
	NetworkPluginServer::Backend *c = NULL;
 

	
 
	unsigned long diff = CONFIG_INT(m_config, "service.login_delay");
 
	long diff = CONFIG_INT(m_config, "service.login_delay");
 
	time_t now = time(NULL);
 
	if (diff && (now - m_lastLogin < diff)) {
 
		m_loginTimer->stop();
 
		m_loginTimer = m_component->getNetworkFactories()->getTimerFactory()->createTimer((diff - (now - m_lastLogin)) * 1000);
 
		m_loginTimer->onTick.connect(boost::bind(&NetworkPluginServer::loginDelayFinished, this));
 
		m_loginTimer->start();
 
@@ -2074,17 +2074,17 @@ NetworkPluginServer::Backend *NetworkPluginServer::getFreeClient(bool acceptUser
 
	if (!check) {
 
		m_lastLogin = time(NULL);
 
	}
 

	
 
	// Check all backends and find free one
 
	for (std::list<Backend *>::const_iterator it = m_clients.begin(); it != m_clients.end(); it++) {
 
		if ((*it)->willDie == false && (*it)->acceptUsers == acceptUsers && (*it)->users.size() < CONFIG_INT(m_config, "service.users_per_backend") && (*it)->connection && (*it)->longRun == longRun) {
 
		if ((*it)->willDie == false && (*it)->acceptUsers == acceptUsers && (int) (*it)->users.size() < CONFIG_INT(m_config, "service.users_per_backend") && (*it)->connection && (*it)->longRun == longRun) {
 
			c = *it;
 
			// if we're not reusing all backends and backend is full, stop accepting new users on this backend
 
			if (!CONFIG_BOOL(m_config, "service.reuse_old_backends")) {
 
				if (!check && c->users.size() + 1 >= CONFIG_INT(m_config, "service.users_per_backend")) {
 
				if (!check && (int) c->users.size() + 1 >= CONFIG_INT(m_config, "service.users_per_backend")) {
 
					c->acceptUsers = false;
 
				}
 
			}
 
			break;
 
		}
 
	}
libtransport/StorageBackend.cpp
Show inline comments
 
@@ -49,13 +49,13 @@ StorageBackend *StorageBackend::createBackend(Config *config, std::string &error
 
	return storageBackend;
 
}
 

	
 
std::string StorageBackend::encryptPassword(const std::string &password, const std::string &key) {
 
	std::string encrypted;
 
	encrypted.resize(password.size());
 
	for (int i = 0; i < password.size(); i++) {
 
	for (unsigned i = 0; i < password.size(); i++) {
 
		char c = password[i];
 
		char keychar = key[i % key.size()];
 
		c += keychar;
 
		encrypted[i] = c;
 
	}
 

	
 
@@ -64,13 +64,13 @@ std::string StorageBackend::encryptPassword(const std::string &password, const s
 
}
 

	
 
std::string StorageBackend::decryptPassword(std::string &encrypted, const std::string &key) {
 
	encrypted = Swift::byteArrayToString(Swift::Base64::decode(encrypted));
 
	std::string password;
 
	password.resize(encrypted.size());
 
	for (int i = 0; i < encrypted.size(); i++) {
 
	for (unsigned i = 0; i < encrypted.size(); i++) {
 
		char c = encrypted[i];
 
		char keychar = key[i % key.size()];
 
		c -= keychar;
 
		password[i] = c;
 
	}
 

	
spectrum/src/frontends/slack/SlackAPI.cpp
Show inline comments
 
@@ -180,13 +180,13 @@ std::string SlackAPI::getOwnerId(HTTPRequest *req, bool ok, rapidjson::Document
 
	rapidjson::Value &members = resp["members"];
 
	if (!members.IsArray()) {
 
		LOG4CXX_ERROR(logger, "No 'members' object in the reply.");
 
		return "";
 
	}
 

	
 
	for (int i = 0; i < members.Size(); i++) {
 
	for (unsigned i = 0; i < members.Size(); i++) {
 
		if (!members[i].IsObject()) {
 
			continue;
 
		}
 

	
 
		rapidjson::Value &is_primary_owner = members[i]["is_primary_owner"];
 
		if (!is_primary_owner.IsBool()) {
 
@@ -228,26 +228,26 @@ void SlackAPI::getSlackChannelInfo(HTTPRequest *req, bool ok, rapidjson::Documen
 
			info.id = id;
 

	
 
			STORE_STRING(channel, name);
 
			info.name = name;
 

	
 
			rapidjson::Value &members = channel["members"];
 
			for (int y = 0; members.IsArray() && y < members.Size(); y++) {
 
			for (unsigned y = 0; members.IsArray() && y < members.Size(); y++) {
 
				if (!members[y].IsString()) {
 
					continue;
 
				}
 

	
 
				info.members.push_back(members[y].GetString());
 
			}
 

	
 
			ret[info.name] = info;
 
		}
 
		return;
 
	}
 

	
 
	for (int i = 0; i < channels.Size(); i++) {
 
	for (unsigned i = 0; i < channels.Size(); i++) {
 
		if (!channels[i].IsObject()) {
 
			continue;
 
		}
 

	
 
		SlackChannelInfo info;
 

	
 
@@ -255,13 +255,13 @@ void SlackAPI::getSlackChannelInfo(HTTPRequest *req, bool ok, rapidjson::Documen
 
		info.id = id;
 

	
 
		STORE_STRING(channels[i], name);
 
		info.name = name;
 

	
 
		rapidjson::Value &members = channels[i]["members"];
 
		for (int y = 0; members.IsArray() && y < members.Size(); y++) {
 
		for (unsigned y = 0; members.IsArray() && y < members.Size(); y++) {
 
			if (!members[y].IsString()) {
 
				continue;
 
			}
 

	
 
			info.members.push_back(members[y].GetString());
 
		}
 
@@ -277,13 +277,13 @@ void SlackAPI::getSlackImInfo(HTTPRequest *req, bool ok, rapidjson::Document &re
 
		LOG4CXX_ERROR(logger, req->getError());
 
		return;
 
	}
 

	
 
	GET_ARRAY(resp, ims);
 

	
 
	for (int i = 0; i < ims.Size(); i++) {
 
	for (unsigned i = 0; i < ims.Size(); i++) {
 
		if (!ims[i].IsObject()) {
 
			continue;
 
		}
 

	
 
		SlackImInfo info;
 

	
 
@@ -305,13 +305,13 @@ void SlackAPI::getSlackUserInfo(HTTPRequest *req, bool ok, rapidjson::Document &
 
		LOG4CXX_ERROR(logger, req->getError());
 
		return;
 
	}
 

	
 
	GET_ARRAY(resp, users);
 

	
 
	for (int i = 0; i < users.Size(); i++) {
 
	for (unsigned i = 0; i < users.Size(); i++) {
 
		if (!users[i].IsObject()) {
 
			continue;
 
		}
 

	
 
		SlackUserInfo info;
 

	
 
@@ -334,13 +334,13 @@ void SlackAPI::getSlackUserInfo(HTTPRequest *req, bool ok, rapidjson::Document &
 
			LOG4CXX_INFO(logger, bot_id << " " << info.name);
 
		}
 
	}
 

	
 
	GET_ARRAY(resp, bots);
 

	
 
	for (int i = 0; i < bots.Size(); i++) {
 
	for (unsigned i = 0; i < bots.Size(); i++) {
 
		if (!bots[i].IsObject()) {
 
			continue;
 
		}
 

	
 
		SlackUserInfo info;
 

	
spectrum/src/frontends/slack/SlackRTM.cpp
Show inline comments
 
@@ -116,13 +116,13 @@ void SlackRTM::handlePayloadReceived(const std::string &payload) {
 
		STORE_STRING(d, ts);
 
		STORE_STRING_OPTIONAL(d, subtype);
 
		STORE_STRING_OPTIONAL(d, purpose);
 

	
 
		rapidjson::Value &attachments = d["attachments"];
 
		if (attachments.IsArray()) {
 
			for (int i = 0; i < attachments.Size(); i++) {
 
			for (unsigned i = 0; i < attachments.Size(); i++) {
 
				STORE_STRING_OPTIONAL(attachments[i], fallback);
 
				if (!fallback.empty()) {
 
					text += fallback;
 
				}
 
			}
 
		}
spectrum/src/frontends/xmpp/discoitemsresponder.cpp
Show inline comments
 
@@ -57,13 +57,13 @@ DiscoItemsResponder::~DiscoItemsResponder() {
 
void DiscoItemsResponder::addAdHocCommand(const std::string &node, const std::string &name) {
 
	m_commands->addItem(DiscoItems::Item(name, m_component->getJID(), node));
 
	m_discoInfoResponder->addAdHocCommand(node, name);
 
}
 

	
 
void DiscoItemsResponder::addRoom(const std::string &node, const std::string &name) {
 
	if (m_rooms->getItems().size() > CONFIG_INT(m_component->getConfig(), "service.max_room_list_size")) {
 
	if ((int) m_rooms->getItems().size() > CONFIG_INT(m_component->getConfig(), "service.max_room_list_size")) {
 
		return;
 
	}
 
	m_rooms->addItem(DiscoItems::Item(name, node));
 
	m_discoInfoResponder->addRoom(node, name);
 
}
 

	
spectrum/src/main.cpp
Show inline comments
 
@@ -75,12 +75,13 @@ BOOL spectrum_control_handler( DWORD fdwCtrlType ) {
 
		return TRUE;
 
	}
 
	return FALSE;
 
}
 
#endif
 

	
 
__attribute__ ((unused))
 
static void removeOldIcons(std::string iconDir) {
 
	std::vector<std::string> dirs;
 
	dirs.push_back(iconDir);
 

	
 
	boost::thread thread(boost::bind(Util::removeEverythingOlderThan, dirs, time(NULL) - 3600*24*14));
 
}
spectrum_manager/src/APIServer.cpp
Show inline comments
 
@@ -239,13 +239,12 @@ void APIServer::serve_instances_register(Server *server, Server::session *sessio
 
			send_json(conn, json);
 
		}
 
		else {
 
			response = server->send_command(instance, "register " + jid + " " + uin + " " + password);
 
			if (!response.empty()) {
 
				std::string value = jid;
 
				int type = (int) TYPE_STRING;
 
				m_storage->updateUserSetting(info.id, instance, value);
 
				send_ack(conn, false, response);
 
			}
 
			else {
 
				send_ack(conn, true, response);
 
				return;
spectrum_manager/src/main.cpp
Show inline comments
 
@@ -153,13 +153,12 @@ int main(int argc, char **argv)
 
		eventLoop.runUntilEvents();
 

	
 
		struct timeval td_start,td_end;
 
		float elapsed = 0; 
 
		gettimeofday(&td_start, NULL);
 
	
 
		time_t started = time(NULL);
 
		while(get_response().empty()) {
 
			eventLoop.runUntilEvents();
 
		}
 
		if (!get_response().empty()) {
 
			gettimeofday(&td_end, NULL);
 
			elapsed = 1000000.0 * (td_end.tv_sec -td_start.tv_sec); \
spectrum_manager/src/methods.cpp
Show inline comments
 
@@ -40,13 +40,13 @@ std::string get_response() {
 
std::string searchForBinary(const std::string &binary) {
 
	std::vector<std::string> path_list;
 
	char * env_path = getenv("PATH");
 

	
 
	if (env_path != NULL) {
 
		std::string buffer = "";
 
		for (int s = 0; s < strlen(env_path); s++) {
 
		for (unsigned s = 0; s < strlen(env_path); s++) {
 
			if (env_path[s] == ':') {
 
				path_list.insert(path_list.end(), std::string(buffer));
 
				buffer = "";
 
			}
 
			else {
 
				buffer += env_path[s];
 
@@ -616,13 +616,12 @@ std::vector<std::string> show_list(ManagerConfig *config, bool show) {
 

	
 
		if (!is_directory(p)) {
 
			std::cerr << "Config directory " << CONFIG_STRING(config, "service.config_directory") << " does not exist\n";
 
			return list;
 
		}
 

	
 
		bool found = false;
 
		directory_iterator end_itr;
 
		for (directory_iterator itr(p); itr != end_itr; ++itr) {
 
			if (is_regular(itr->path()) && extension(itr->path()) == ".cfg") {
 
				Config cfg;
 
				if (cfg.load(itr->path().string()) == false) {
 
					std::cerr << "Can't load config file " << itr->path().string() << ". Skipping...\n";
spectrum_manager/src/server.cpp
Show inline comments
 
@@ -284,30 +284,29 @@ void Server::redirect_to(struct mg_connection *conn, struct http_message *hm, co
 
}
 

	
 
void Server::print_html(struct mg_connection *conn, struct http_message *hm, const std::string &html) {
 
	mg_printf(conn,
 
			"HTTP/1.1 200 OK\r\n"
 
			"Content-Type: text/html\r\n"
 
			"Content-Length: %d\r\n"        // Always set Content-Length
 
			"Content-Length: %zu\r\n"        // Always set Content-Length
 
			"\r\n"
 
			"%s%s%s",
 
			(int) html.size() + m_header.size() + m_footer.size(), m_header.c_str(), html.c_str(), m_footer.c_str());
 
}
 

	
 
std::string Server::send_command(const std::string &jid, const std::string &cmd, int timeout) {
 
	Swift::SimpleEventLoop eventLoop;
 
	Swift::BoostNetworkFactories networkFactories(&eventLoop);
 

	
 
	try {
 
		ask_local_server(m_config, networkFactories, jid, cmd);
 
		struct timeval td_start, td_end;
 
		float elapsed = 0; 
 

	
 
		gettimeofday(&td_start, NULL);
 
		gettimeofday(&td_end, NULL);
 

	
 
		time_t started = time(NULL);
 
		while (get_response().empty() && td_end.tv_sec - td_start.tv_sec < timeout) {
 
			gettimeofday(&td_end, NULL);
 
			eventLoop.runOnce();
 
		}
 
	}
 
	catch (const boost::bad_any_cast &e) {
 
@@ -397,13 +396,13 @@ void Server::serve_logout(struct mg_connection *conn, struct http_message *hm) {
 
		else {
 
			host += "http://";
 
		}
 
		host += std::string(host_hdr->p, host_hdr->len);
 
	}
 

	
 
	Server:session *session = get_session(hm);
 
	Server::session *session = get_session(hm);
 
	mg_printf(conn, "HTTP/1.1 302 Found\r\n"
 
		"Set-Cookie: session=%s; max-age=0\r\n"
 
		"Set-Cookie: admin=%s; max-age=0\r\n"
 
		"Location: %s%s\r\n\r\n",
 
		session->session_id, session->admin ? "1" : "0", host.c_str(), CONFIG_STRING(m_config, "service.base_location").c_str());
 

	
 
@@ -422,13 +421,13 @@ void Server::serve_oauth2(struct mg_connection *conn, struct http_message *hm) {
 
	std::cerr << "set_oauth2_code response: '" << response << "'\n";
 
	if (response.find("Registered as ") == 0) {
 
		std::vector<std::string> args;
 
		boost::split(args, response, boost::is_any_of(" "));
 
		std::cerr << "set_oauth2_code response size " << args.size() << "\n";
 
		if (args.size() == 3) {
 
			Server:session *session = get_session(hm);
 
			Server::session *session = get_session(hm);
 
			UserInfo info;
 
			m_storage->getUser(session->user, info);
 
			std::string username = "";
 
			int type = (int) TYPE_STRING;
 
			m_storage->getUserSetting(info.id, instance, type, username);
 
			m_storage->updateUserSetting(info.id, instance, args[2]);
0 comments (0 inline, 0 general)