Ejemplo n.º 1
0
static GDateTime* daemon_data_sqlite_data_real_UserLastSeen (DaemonDataIDataAccess* base, const gchar* username, const gchar* channel, const gchar* server, GError** error) {
	DaemonDataSqliteData * self;
	GDateTime* result = NULL;
	gchar* _tmp0_;
	gchar* commandText;
	sqlite3_stmt* statement = NULL;
	sqlite3_stmt* _tmp1_ = NULL;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	gint64 _tmp8_;
	GDateTime* _tmp9_ = NULL;
	self = (DaemonDataSqliteData*) base;
	g_return_val_if_fail (username != NULL, NULL);
	g_return_val_if_fail (channel != NULL, NULL);
	g_return_val_if_fail (server != NULL, NULL);
	_tmp0_ = g_strdup ("SELECT Timestamp,Type FROM Log WHERE Username = @1 AND Channel = @2 AN" \
"D Server = @3 ORDER BY Timestamp DESC LIMIT 1");
	commandText = _tmp0_;
	sqlite3_prepare_v2 (self->priv->_database, commandText, -1, &_tmp1_, NULL);
	_sqlite3_finalize0 (statement);
	statement = _tmp1_;
	_tmp2_ = g_strdup (username);
	sqlite3_bind_text (statement, 1, _tmp2_, -1, g_free);
	_tmp3_ = g_strdup (channel);
	sqlite3_bind_text (statement, 2, _tmp3_, -1, g_free);
	_tmp4_ = g_strdup (server);
	sqlite3_bind_text (statement, 3, _tmp4_, -1, g_free);
	_tmp5_ = sqlite3_step (statement);
	if (_tmp5_ != SQLITE_ROW) {
		result = NULL;
		_sqlite3_finalize0 (statement);
		_g_free0 (commandText);
		return result;
	}
	_tmp6_ = sqlite3_column_int (statement, 1);
	if (_tmp6_ != ((gint) DAEMON_DATA_EVENT_TYPES_Left)) {
		GDateTime* _tmp7_ = NULL;
		_tmp7_ = g_date_time_new_now_local ();
		result = _tmp7_;
		_sqlite3_finalize0 (statement);
		_g_free0 (commandText);
		return result;
	}
	_tmp8_ = sqlite3_column_int64 (statement, 0);
	_tmp9_ = daemon_helpers_date_time_converter_FromUnixTimestamp (_tmp8_);
	result = _tmp9_;
	_sqlite3_finalize0 (statement);
	_g_free0 (commandText);
	return result;
}
Ejemplo n.º 2
0
void irc_sq_lite_db_Insert (IRCMessage* message) {
	char* commandText;
	sqlite3_stmt* statement;
	sqlite3_stmt* _tmp0_ = NULL;
	sqlite3_stmt* _tmp1_;
	g_return_if_fail (message != NULL);
	if (irc_sq_lite_db_DataBase == NULL) {
		fprintf (stdout, "Datenbank wird erstellt!\n");
		irc_sq_lite_db_CreateDB ();
	}
	commandText = g_strdup ("INSERT INTO MyLogData (Username, Message, Channel, Server, Timestamp) " \
"VALUES (@1, @2, @3, @4, @5)");
	statement = NULL;
	sqlite3_prepare_v2 (irc_sq_lite_db_DataBase, commandText, -1, &_tmp0_, NULL);
	statement = (_tmp1_ = _tmp0_, _sqlite3_finalize0 (statement), _tmp1_);
	sqlite3_bind_text (statement, 1, g_strdup (irc_message_get_Username (message)), -1, g_free);
	sqlite3_bind_text (statement, 2, g_strdup (irc_message_get_MessageContent (message)), -1, g_free);
	sqlite3_bind_text (statement, 3, g_strdup (irc_message_get_Channel (message)), -1, g_free);
	sqlite3_bind_text (statement, 4, g_strdup (irc_message_get_Server (message)), -1, g_free);
	sqlite3_bind_int64 (statement, 5, irc_message_get_UnixTime (message));
	sqlite3_step (statement);
	_sqlite3_finalize0 (statement);
	_g_free0 (commandText);
}
Ejemplo n.º 3
0
static GList* daemon_data_sqlite_data_real_GetLog (DaemonDataIDataAccess* base, const gchar* channel, const gchar* server, GError** error) {
	DaemonDataSqliteData * self;
	GList* result = NULL;
	gchar* _tmp0_;
	gchar* commandText;
	sqlite3_stmt* statement = NULL;
	sqlite3_stmt* _tmp1_ = NULL;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gint _result_;
	GList* results;
	GError * _inner_error_ = NULL;
	self = (DaemonDataSqliteData*) base;
	g_return_val_if_fail (channel != NULL, NULL);
	g_return_val_if_fail (server != NULL, NULL);
	_tmp0_ = g_strdup ("SELECT * FROM Log WHERE Channel = @1 AND Server = @2 ORDER BY Timestam" \
"p DESC LIMIT 50");
	commandText = _tmp0_;
	sqlite3_prepare_v2 (self->priv->_database, commandText, -1, &_tmp1_, NULL);
	_sqlite3_finalize0 (statement);
	statement = _tmp1_;
	_tmp2_ = g_strdup (channel);
	sqlite3_bind_text (statement, 1, _tmp2_, -1, g_free);
	_tmp3_ = g_strdup (server);
	sqlite3_bind_text (statement, 2, _tmp3_, -1, g_free);
	_result_ = 0;
	results = NULL;
	{
		gboolean _tmp4_;
		_tmp4_ = TRUE;
		while (TRUE) {
			gint _tmp5_;
			if (!_tmp4_) {
				if (!(_result_ == SQLITE_ROW)) {
					break;
				}
			}
			_tmp4_ = FALSE;
			_tmp5_ = sqlite3_step (statement);
			_result_ = _tmp5_;
			switch (_result_) {
				case SQLITE_DONE:
				{
					{
						break;
					}
				}
				case SQLITE_ROW:
				{
					{
						const gchar* _tmp6_ = NULL;
						gchar* _tmp7_;
						gchar* username;
						const gchar* _tmp8_ = NULL;
						gchar* _tmp9_;
						gchar* data;
						const gchar* _tmp10_ = NULL;
						gchar* _tmp11_;
						gchar* eventChannel;
						const gchar* _tmp12_ = NULL;
						gchar* _tmp13_;
						gchar* eventServer;
						gint64 _tmp14_;
						GDateTime* _tmp15_ = NULL;
						GDateTime* timestamp;
						gint _tmp16_;
						DaemonDataEventTypes type;
						DaemonEventsLogEvent* current;
						DaemonEventsLogEvent* _tmp21_;
						_tmp6_ = sqlite3_column_text (statement, 0);
						_tmp7_ = g_strdup (_tmp6_);
						username = _tmp7_;
						_tmp8_ = sqlite3_column_text (statement, 1);
						_tmp9_ = g_strdup (_tmp8_);
						data = _tmp9_;
						_tmp10_ = sqlite3_column_text (statement, 2);
						_tmp11_ = g_strdup (_tmp10_);
						eventChannel = _tmp11_;
						_tmp12_ = sqlite3_column_text (statement, 3);
						_tmp13_ = g_strdup (_tmp12_);
						eventServer = _tmp13_;
						_tmp14_ = sqlite3_column_int64 (statement, 4);
						_tmp15_ = daemon_helpers_date_time_converter_FromUnixTimestamp (_tmp14_);
						timestamp = _tmp15_;
						_tmp16_ = sqlite3_column_int (statement, 5);
						type = (DaemonDataEventTypes) _tmp16_;
						current = NULL;
						switch (type) {
							case DAEMON_DATA_EVENT_TYPES_Joined:
							{
								{
									DaemonEventsStatusEvent* _tmp17_ = NULL;
									_tmp17_ = daemon_events_status_event_new_WithTimestamp (username, DAEMON_EVENTS_STATUS_CHANGE_Join, eventChannel, eventServer, timestamp);
									_g_object_unref0 (current);
									current = (DaemonEventsLogEvent*) _tmp17_;
									break;
								}
							}
							case DAEMON_DATA_EVENT_TYPES_Left:
							{
								{
									DaemonEventsStatusEvent* _tmp18_ = NULL;
									_tmp18_ = daemon_events_status_event_new_WithTimestamp (username, DAEMON_EVENTS_STATUS_CHANGE_Leave, eventChannel, eventServer, timestamp);
									_g_object_unref0 (current);
									current = (DaemonEventsLogEvent*) _tmp18_;
									break;
								}
							}
							case DAEMON_DATA_EVENT_TYPES_ChangedName:
							{
								{
									DaemonEventsChangeNameEvent* _tmp19_ = NULL;
									_tmp19_ = daemon_events_change_name_event_new_WithTimestamp (username, data, eventChannel, eventServer, timestamp);
									_g_object_unref0 (current);
									current = (DaemonEventsLogEvent*) _tmp19_;
									break;
								}
							}
							case DAEMON_DATA_EVENT_TYPES_Message:
							{
								{
									DaemonEventsMessageEvent* _tmp20_ = NULL;
									_tmp20_ = daemon_events_message_event_new_WithTimestamp (username, data, eventChannel, eventServer, timestamp);
									_g_object_unref0 (current);
									current = (DaemonEventsLogEvent*) _tmp20_;
									break;
								}
							}
							default:
							break;
						}
						_tmp21_ = _g_object_ref0 (current);
						results = g_list_append (results, _tmp21_);
						_g_object_unref0 (current);
						_g_date_time_unref0 (timestamp);
						_g_free0 (eventServer);
						_g_free0 (eventChannel);
						_g_free0 (data);
						_g_free0 (username);
						break;
					}
				}
				default:
				{
					{
						const gchar* _tmp22_ = NULL;
						GError* _tmp23_ = NULL;
						_tmp22_ = sqlite3_errmsg (self->priv->_database);
						_tmp23_ = g_error_new_literal (DAEMON_DATA_DATA_ACCESS_ERROR, DAEMON_DATA_DATA_ACCESS_ERROR_ReadError, _tmp22_);
						_inner_error_ = _tmp23_;
						if (_inner_error_->domain == DAEMON_DATA_DATA_ACCESS_ERROR) {
							g_propagate_error (error, _inner_error_);
							__g_list_free__g_object_unref0_0 (results);
							_sqlite3_finalize0 (statement);
							_g_free0 (commandText);
							return NULL;
						} else {
							__g_list_free__g_object_unref0_0 (results);
							_sqlite3_finalize0 (statement);
							_g_free0 (commandText);
							g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
							g_clear_error (&_inner_error_);
							return NULL;
						}
					}
				}
			}
		}
	}
	result = results;
	_sqlite3_finalize0 (statement);
	_g_free0 (commandText);
	return result;
}
Ejemplo n.º 4
0
void daemon_data_sqlite_data_LogMessageEvent (DaemonDataSqliteData* self, DaemonEventsMessageEvent* event, GError** error) {
	gchar* _tmp0_;
	gchar* commandText;
	sqlite3_stmt* statement = NULL;
	sqlite3_stmt* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	gchar* _tmp3_;
	const gchar* _tmp4_ = NULL;
	gchar* _tmp5_;
	const gchar* _tmp6_ = NULL;
	gchar* _tmp7_;
	const gchar* _tmp8_ = NULL;
	gchar* _tmp9_;
	gint64 _tmp10_;
	gint _tmp11_;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (event != NULL);
	_tmp0_ = g_strdup ("INSERT INTO Log (Username, Data, Channel, Server, Timestamp, Type) VAL" \
"UES (@1, @2, @3, @4, @5, @6)");
	commandText = _tmp0_;
	sqlite3_prepare_v2 (self->priv->_database, commandText, -1, &_tmp1_, NULL);
	_sqlite3_finalize0 (statement);
	statement = _tmp1_;
	_tmp2_ = daemon_events_log_event_get_Username ((DaemonEventsLogEvent*) event);
	_tmp3_ = g_strdup (_tmp2_);
	sqlite3_bind_text (statement, 1, _tmp3_, -1, g_free);
	_tmp4_ = daemon_events_message_event_get_Message (event);
	_tmp5_ = g_strdup (_tmp4_);
	sqlite3_bind_text (statement, 2, _tmp5_, -1, g_free);
	_tmp6_ = daemon_events_log_event_get_Channel ((DaemonEventsLogEvent*) event);
	_tmp7_ = g_strdup (_tmp6_);
	sqlite3_bind_text (statement, 3, _tmp7_, -1, g_free);
	_tmp8_ = daemon_events_log_event_get_Server ((DaemonEventsLogEvent*) event);
	_tmp9_ = g_strdup (_tmp8_);
	sqlite3_bind_text (statement, 4, _tmp9_, -1, g_free);
	_tmp10_ = daemon_events_log_event_get_UnixTimestamp ((DaemonEventsLogEvent*) event);
	sqlite3_bind_int64 (statement, 5, _tmp10_);
	sqlite3_bind_int (statement, 6, (gint) DAEMON_DATA_EVENT_TYPES_Message);
	_tmp11_ = sqlite3_step (statement);
	if (_tmp11_ != SQLITE_DONE) {
		const gchar* _tmp12_ = NULL;
		GError* _tmp13_ = NULL;
		_tmp12_ = sqlite3_errmsg (self->priv->_database);
		_tmp13_ = g_error_new_literal (DAEMON_DATA_DATA_ACCESS_ERROR, DAEMON_DATA_DATA_ACCESS_ERROR_WriteError, _tmp12_);
		_inner_error_ = _tmp13_;
		if (_inner_error_->domain == DAEMON_DATA_DATA_ACCESS_ERROR) {
			g_propagate_error (error, _inner_error_);
			_sqlite3_finalize0 (statement);
			_g_free0 (commandText);
			return;
		} else {
			_sqlite3_finalize0 (statement);
			_g_free0 (commandText);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
	_sqlite3_finalize0 (statement);
	_g_free0 (commandText);
}
Ejemplo n.º 5
0
void irc_sq_lite_db_ShowLog (const char* username) {
	sqlite3* _tmp0_ = NULL;
	sqlite3* _tmp1_;
	char* commandText;
	sqlite3_stmt* statement;
	sqlite3_stmt* _tmp2_ = NULL;
	sqlite3_stmt* _tmp3_;
	gint _result_;
	GList* results;
	g_return_if_fail (username != NULL);
	fprintf (stdout, "Datenbank wird ausgelesen!\n");
	sqlite3_open (IRC_SQ_LITE_DB__path, &_tmp0_);
	irc_sq_lite_db_DataBase = (_tmp1_ = _tmp0_, _sqlite3_close0 (irc_sq_lite_db_DataBase), _tmp1_);
	commandText = g_strdup ("SELECT * FROM MyLogData WHERE Username = @1 ORDER BY Timestamp DESC LI" \
"MIT 10");
	statement = NULL;
	sqlite3_prepare_v2 (irc_sq_lite_db_DataBase, commandText, -1, &_tmp2_, NULL);
	statement = (_tmp3_ = _tmp2_, _sqlite3_finalize0 (statement), _tmp3_);
	sqlite3_bind_text (statement, 1, g_strdup (username), -1, g_free);
	_result_ = sqlite3_step (statement);
	results = NULL;
	while (TRUE) {
		char* Username;
		char* MessageContent;
		char* Channel;
		char* Server;
		GDateTime* FromUnixTime;
		IRCMessage* msg;
		if (!(_result_ == SQLITE_ROW)) {
			break;
		}
		Username = g_strdup (sqlite3_column_text (statement, 0));
		MessageContent = g_strdup (sqlite3_column_text (statement, 1));
		Channel = g_strdup (sqlite3_column_text (statement, 2));
		Server = g_strdup (sqlite3_column_text (statement, 3));
		FromUnixTime = g_date_time_new_from_unix_local (g_ascii_strtoll (sqlite3_column_text (statement, 4), NULL, 0));
		msg = irc_message_new (Username, MessageContent, Channel, Server, FromUnixTime);
		results = g_list_append (results, _irc_message_ref0 (msg));
		_result_ = sqlite3_step (statement);
		_irc_message_unref0 (msg);
		_g_date_time_unref0 (FromUnixTime);
		_g_free0 (Server);
		_g_free0 (Channel);
		_g_free0 (MessageContent);
		_g_free0 (Username);
	}
	{
		GList* r_collection;
		GList* r_it;
		r_collection = results;
		for (r_it = r_collection; r_it != NULL; r_it = r_it->next) {
			IRCMessage* r;
			r = _irc_message_ref0 ((IRCMessage*) r_it->data);
			{
				fprintf (stdout, "%s\n", irc_message_get_MessageContent (r));
				_irc_message_unref0 (r);
			}
		}
	}
	__g_list_free_irc_message_unref0 (results);
	_sqlite3_finalize0 (statement);
	_g_free0 (commandText);
}
Ejemplo n.º 6
0
GeeArrayList* graph_media_modelos_sentimientos_lista_sentimientos (GraphMediaModelosSentimientos* self) {
	GeeArrayList* result = NULL;
	sqlite3_stmt* query = NULL;
	gchar* sql = NULL;
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	gchar* _tmp4_ = NULL;
	gint res = 0;
	sqlite3* _tmp5_ = NULL;
	const gchar* _tmp6_ = NULL;
	sqlite3_stmt* _tmp7_ = NULL;
	gint _tmp8_ = 0;
	gint _tmp9_ = 0;
	GeeArrayList* sentimientos = NULL;
	GeeArrayList* _tmp10_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = ((GraphMediaModelosTablas*) self)->nombre_tabla;
	_tmp1_ = g_strdup_printf ("FROM %s WHERE 1", _tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strconcat ("SELECT id, nombre, descripcion ", _tmp2_, NULL);
	_tmp4_ = _tmp3_;
	_g_free0 (_tmp2_);
	sql = _tmp4_;
	_tmp5_ = graph_media_modelos_tablas_bd;
	_tmp6_ = sql;
	_tmp8_ = sqlite3_prepare_v2 (_tmp5_, _tmp6_, -1, &_tmp7_, NULL);
	_sqlite3_finalize0 (query);
	query = _tmp7_;
	res = _tmp8_;
	_tmp9_ = res;
	_vala_assert (_tmp9_ == SQLITE_OK, "res == Sqlite.OK");
	_tmp10_ = gee_array_list_new (GRAPH_MEDIA_MODELOS_TYPE_SENTIMIENTO, (GBoxedCopyFunc) graph_media_modelos_sentimiento_ref, graph_media_modelos_sentimiento_unref, NULL, NULL, NULL);
	sentimientos = _tmp10_;
	while (TRUE) {
		sqlite3_stmt* _tmp11_ = NULL;
		gint _tmp12_ = 0;
		gint _tmp13_ = 0;
		GraphMediaModelosSentimiento* celda = NULL;
		GraphMediaModelosSentimiento* _tmp14_ = NULL;
		GraphMediaModelosSentimiento* _tmp15_ = NULL;
		sqlite3_stmt* _tmp16_ = NULL;
		gint64 _tmp17_ = 0LL;
		GraphMediaModelosSentimiento* _tmp18_ = NULL;
		sqlite3_stmt* _tmp19_ = NULL;
		const gchar* _tmp20_ = NULL;
		gchar* _tmp21_ = NULL;
		GraphMediaModelosSentimiento* _tmp22_ = NULL;
		sqlite3_stmt* _tmp23_ = NULL;
		const gchar* _tmp24_ = NULL;
		gchar* _tmp25_ = NULL;
		GeeArrayList* _tmp26_ = NULL;
		GraphMediaModelosSentimiento* _tmp27_ = NULL;
		_tmp11_ = query;
		_tmp12_ = sqlite3_step (_tmp11_);
		res = _tmp12_;
		_tmp13_ = res;
		if (!(_tmp13_ == SQLITE_ROW)) {
			break;
		}
		_tmp14_ = graph_media_modelos_sentimiento_new ();
		celda = _tmp14_;
		_tmp15_ = celda;
		_tmp16_ = query;
		_tmp17_ = sqlite3_column_int64 (_tmp16_, 0);
		_tmp15_->id = _tmp17_;
		_tmp18_ = celda;
		_tmp19_ = query;
		_tmp20_ = sqlite3_column_text (_tmp19_, 1);
		_tmp21_ = g_strdup (_tmp20_);
		_g_free0 (_tmp18_->nombre);
		_tmp18_->nombre = _tmp21_;
		_tmp22_ = celda;
		_tmp23_ = query;
		_tmp24_ = sqlite3_column_text (_tmp23_, 2);
		_tmp25_ = g_strdup (_tmp24_);
		_g_free0 (_tmp22_->descripcion);
		_tmp22_->descripcion = _tmp25_;
		_tmp26_ = sentimientos;
		_tmp27_ = celda;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp26_, _tmp27_);
		_graph_media_modelos_sentimiento_unref0 (celda);
	}
	result = sentimientos;
	_g_free0 (sql);
	_sqlite3_finalize0 (query);
	return result;
}
Ejemplo n.º 7
0
GraphMediaModelosSentimiento* graph_media_modelos_sentimientos_get_sentimiento_por_id (GraphMediaModelosSentimientos* self, gint64 id) {
	GraphMediaModelosSentimiento* result = NULL;
	sqlite3_stmt* query = NULL;
	gint64 _tmp0_ = 0LL;
	gboolean _tmp1_ = FALSE;
	gchar* sql = NULL;
	const gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	gint res = 0;
	sqlite3* _tmp4_ = NULL;
	const gchar* _tmp5_ = NULL;
	sqlite3_stmt* _tmp6_ = NULL;
	gint _tmp7_ = 0;
	gint _tmp8_ = 0;
	sqlite3_stmt* _tmp9_ = NULL;
	gint64 _tmp10_ = 0LL;
	gint _tmp11_ = 0;
	gint _tmp12_ = 0;
	sqlite3_stmt* _tmp13_ = NULL;
	gint _tmp14_ = 0;
	gint _tmp15_ = 0;
	GraphMediaModelosSentimiento* celda = NULL;
	GraphMediaModelosSentimiento* _tmp16_ = NULL;
	GraphMediaModelosSentimiento* _tmp17_ = NULL;
	sqlite3_stmt* _tmp18_ = NULL;
	gint64 _tmp19_ = 0LL;
	GraphMediaModelosSentimiento* _tmp20_ = NULL;
	sqlite3_stmt* _tmp21_ = NULL;
	const gchar* _tmp22_ = NULL;
	gchar* _tmp23_ = NULL;
	GraphMediaModelosSentimiento* _tmp24_ = NULL;
	sqlite3_stmt* _tmp25_ = NULL;
	const gchar* _tmp26_ = NULL;
	gchar* _tmp27_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = id;
	_tmp1_ = graph_media_modelos_tablas_existe_id ((GraphMediaModelosTablas*) self, _tmp0_);
	if (!_tmp1_) {
		result = NULL;
		_sqlite3_finalize0 (query);
		return result;
	}
	_tmp2_ = ((GraphMediaModelosTablas*) self)->nombre_tabla;
	_tmp3_ = g_strdup_printf ("SELECT %s FROM %s WHERE id=?", "*", _tmp2_);
	sql = _tmp3_;
	_tmp4_ = graph_media_modelos_tablas_bd;
	_tmp5_ = sql;
	_tmp7_ = sqlite3_prepare_v2 (_tmp4_, _tmp5_, -1, &_tmp6_, NULL);
	_sqlite3_finalize0 (query);
	query = _tmp6_;
	res = _tmp7_;
	_tmp8_ = res;
	_vala_assert (_tmp8_ == SQLITE_OK, "res == Sqlite.OK");
	_tmp9_ = query;
	_tmp10_ = id;
	_tmp11_ = sqlite3_bind_int64 (_tmp9_, 1, _tmp10_);
	res = _tmp11_;
	_tmp12_ = res;
	_vala_assert (_tmp12_ == SQLITE_OK, "res == Sqlite.OK");
	_tmp13_ = query;
	_tmp14_ = sqlite3_step (_tmp13_);
	res = _tmp14_;
	_tmp15_ = res;
	_vala_assert (_tmp15_ == SQLITE_ROW, "res == Sqlite.ROW");
	_tmp16_ = graph_media_modelos_sentimiento_new ();
	celda = _tmp16_;
	_tmp17_ = celda;
	_tmp18_ = query;
	_tmp19_ = sqlite3_column_int64 (_tmp18_, 0);
	_tmp17_->id = _tmp19_;
	_tmp20_ = celda;
	_tmp21_ = query;
	_tmp22_ = sqlite3_column_text (_tmp21_, 1);
	_tmp23_ = g_strdup (_tmp22_);
	_g_free0 (_tmp20_->nombre);
	_tmp20_->nombre = _tmp23_;
	_tmp24_ = celda;
	_tmp25_ = query;
	_tmp26_ = sqlite3_column_text (_tmp25_, 2);
	_tmp27_ = g_strdup (_tmp26_);
	_g_free0 (_tmp24_->descripcion);
	_tmp24_->descripcion = _tmp27_;
	result = celda;
	_g_free0 (sql);
	_sqlite3_finalize0 (query);
	return result;
}
Ejemplo n.º 8
0
static gboolean graph_media_modelos_sentimientos_existe_sentimiento (GraphMediaModelosSentimientos* self, GraphMediaModelosSentimiento* s) {
	gboolean result = FALSE;
	sqlite3_stmt* query = NULL;
	GraphMediaModelosSentimiento* _tmp0_ = NULL;
	gint64 _tmp1_ = 0LL;
	gchar* sql = NULL;
	const gchar* _tmp5_ = NULL;
	gchar* _tmp6_ = NULL;
	gchar* _tmp7_ = NULL;
	gchar* _tmp8_ = NULL;
	gchar* _tmp9_ = NULL;
	gint res = 0;
	sqlite3* _tmp10_ = NULL;
	const gchar* _tmp11_ = NULL;
	sqlite3_stmt* _tmp12_ = NULL;
	gint _tmp13_ = 0;
	gint _tmp14_ = 0;
	sqlite3_stmt* _tmp15_ = NULL;
	GraphMediaModelosSentimiento* _tmp16_ = NULL;
	const gchar* _tmp17_ = NULL;
	gchar* _tmp18_ = NULL;
	GDestroyNotify _tmp19_ = NULL;
	gint _tmp20_ = 0;
	gint _tmp21_ = 0;
	sqlite3_stmt* _tmp22_ = NULL;
	gint _tmp23_ = 0;
	gint _tmp24_ = 0;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (s != NULL, FALSE);
	_tmp0_ = s;
	_tmp1_ = _tmp0_->id;
	if (_tmp1_ != ((gint64) (-1))) {
		GraphMediaModelosSentimiento* _tmp2_ = NULL;
		gint64 _tmp3_ = 0LL;
		gboolean _tmp4_ = FALSE;
		_tmp2_ = s;
		_tmp3_ = _tmp2_->id;
		_tmp4_ = graph_media_modelos_tablas_existe_id ((GraphMediaModelosTablas*) self, _tmp3_);
		result = _tmp4_;
		_sqlite3_finalize0 (query);
		return result;
	}
	_tmp5_ = ((GraphMediaModelosTablas*) self)->nombre_tabla;
	_tmp6_ = g_strdup_printf ("FROM %s WHERE nombre=?", _tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = g_strconcat ("SELECT id, nombre, descripcion ", _tmp7_, NULL);
	_tmp9_ = _tmp8_;
	_g_free0 (_tmp7_);
	sql = _tmp9_;
	_tmp10_ = graph_media_modelos_tablas_bd;
	_tmp11_ = sql;
	_tmp13_ = sqlite3_prepare_v2 (_tmp10_, _tmp11_, -1, &_tmp12_, NULL);
	_sqlite3_finalize0 (query);
	query = _tmp12_;
	res = _tmp13_;
	_tmp14_ = res;
	_vala_assert (_tmp14_ == SQLITE_OK, "res == Sqlite.OK");
	_tmp15_ = query;
	_tmp16_ = s;
	_tmp17_ = _tmp16_->nombre;
	_tmp18_ = g_strdup (_tmp17_);
	_tmp19_ = g_free;
	_tmp20_ = sqlite3_bind_text (_tmp15_, 1, _tmp18_, -1, _tmp19_);
	res = _tmp20_;
	_tmp21_ = res;
	_vala_assert (_tmp21_ == SQLITE_OK, "res == Sqlite.OK");
	_tmp22_ = query;
	_tmp23_ = sqlite3_step (_tmp22_);
	res = _tmp23_;
	_tmp24_ = res;
	result = _tmp24_ == SQLITE_ROW;
	_g_free0 (sql);
	_sqlite3_finalize0 (query);
	return result;
}
Ejemplo n.º 9
0
gboolean graph_media_modelos_sentimientos_editar (GraphMediaModelosSentimientos* self, GraphMediaModelosSentimiento* sentimiento) {
	gboolean result = FALSE;
	GraphMediaModelosSentimiento* _tmp0_ = NULL;
	gboolean _tmp1_ = FALSE;
	gchar* columnas = NULL;
	gchar* _tmp2_ = NULL;
	sqlite3_stmt* query = NULL;
	gchar* sql = NULL;
	const gchar* _tmp3_ = NULL;
	const gchar* _tmp4_ = NULL;
	gchar* _tmp5_ = NULL;
	gint res = 0;
	sqlite3* _tmp6_ = NULL;
	const gchar* _tmp7_ = NULL;
	sqlite3_stmt* _tmp8_ = NULL;
	gint _tmp9_ = 0;
	gint _tmp10_ = 0;
	sqlite3_stmt* _tmp11_ = NULL;
	GraphMediaModelosSentimiento* _tmp12_ = NULL;
	const gchar* _tmp13_ = NULL;
	gchar* _tmp14_ = NULL;
	GDestroyNotify _tmp15_ = NULL;
	gint _tmp16_ = 0;
	gint _tmp17_ = 0;
	sqlite3_stmt* _tmp18_ = NULL;
	GraphMediaModelosSentimiento* _tmp19_ = NULL;
	const gchar* _tmp20_ = NULL;
	gchar* _tmp21_ = NULL;
	GDestroyNotify _tmp22_ = NULL;
	gint _tmp23_ = 0;
	gint _tmp24_ = 0;
	sqlite3_stmt* _tmp25_ = NULL;
	GraphMediaModelosSentimiento* _tmp26_ = NULL;
	gint64 _tmp27_ = 0LL;
	gint _tmp28_ = 0;
	gint _tmp29_ = 0;
	sqlite3_stmt* _tmp30_ = NULL;
	gint _tmp31_ = 0;
	gint _tmp32_ = 0;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (sentimiento != NULL, FALSE);
	_tmp0_ = sentimiento;
	_tmp1_ = graph_media_modelos_sentimiento_es_valido (_tmp0_);
	if (!_tmp1_) {
		result = FALSE;
		return result;
	}
	_tmp2_ = g_strdup ("nombre=?, descripcion=?");
	columnas = _tmp2_;
	_tmp3_ = ((GraphMediaModelosTablas*) self)->nombre_tabla;
	_tmp4_ = columnas;
	_tmp5_ = g_strdup_printf ("UPDATE %s SET %s WHERE id=?", _tmp3_, _tmp4_);
	sql = _tmp5_;
	_tmp6_ = graph_media_modelos_tablas_bd;
	_tmp7_ = sql;
	_tmp9_ = sqlite3_prepare_v2 (_tmp6_, _tmp7_, -1, &_tmp8_, NULL);
	_sqlite3_finalize0 (query);
	query = _tmp8_;
	res = _tmp9_;
	_tmp10_ = res;
	_vala_assert (_tmp10_ == SQLITE_OK, "res == Sqlite.OK");
	_tmp11_ = query;
	_tmp12_ = sentimiento;
	_tmp13_ = _tmp12_->nombre;
	_tmp14_ = g_strdup (_tmp13_);
	_tmp15_ = g_free;
	_tmp16_ = sqlite3_bind_text (_tmp11_, 1, _tmp14_, -1, _tmp15_);
	res = _tmp16_;
	_tmp17_ = res;
	_vala_assert (_tmp17_ == SQLITE_OK, "res == Sqlite.OK");
	_tmp18_ = query;
	_tmp19_ = sentimiento;
	_tmp20_ = _tmp19_->descripcion;
	_tmp21_ = g_strdup (_tmp20_);
	_tmp22_ = g_free;
	_tmp23_ = sqlite3_bind_text (_tmp18_, 2, _tmp21_, -1, _tmp22_);
	res = _tmp23_;
	_tmp24_ = res;
	_vala_assert (_tmp24_ == SQLITE_OK, "res == Sqlite.OK");
	_tmp25_ = query;
	_tmp26_ = sentimiento;
	_tmp27_ = _tmp26_->id;
	_tmp28_ = sqlite3_bind_int64 (_tmp25_, 3, _tmp27_);
	res = _tmp28_;
	_tmp29_ = res;
	_vala_assert (_tmp29_ == SQLITE_OK, "res == Sqlite.OK");
	_tmp30_ = query;
	_tmp31_ = sqlite3_step (_tmp30_);
	res = _tmp31_;
	_tmp32_ = res;
	result = _tmp32_ == SQLITE_DONE;
	_g_free0 (sql);
	_sqlite3_finalize0 (query);
	_g_free0 (columnas);
	return result;
}
Ejemplo n.º 10
0
GraphMediaModelosSentimiento* graph_media_modelos_sentimientos_agregar (GraphMediaModelosSentimientos* self, GraphMediaModelosSentimiento* sentimiento) {
	GraphMediaModelosSentimiento* result = NULL;
	GraphMediaModelosSentimiento* _tmp0_ = NULL;
	gboolean _tmp1_ = FALSE;
	sqlite3_stmt* query = NULL;
	gchar* sql = NULL;
	const gchar* _tmp4_ = NULL;
	gchar* _tmp5_ = NULL;
	gchar* _tmp6_ = NULL;
	gchar* _tmp7_ = NULL;
	gchar* _tmp8_ = NULL;
	gint res = 0;
	sqlite3* _tmp9_ = NULL;
	const gchar* _tmp10_ = NULL;
	sqlite3_stmt* _tmp11_ = NULL;
	gint _tmp12_ = 0;
	gint _tmp13_ = 0;
	sqlite3_stmt* _tmp14_ = NULL;
	GraphMediaModelosSentimiento* _tmp15_ = NULL;
	const gchar* _tmp16_ = NULL;
	gchar* _tmp17_ = NULL;
	GDestroyNotify _tmp18_ = NULL;
	gint _tmp19_ = 0;
	gint _tmp20_ = 0;
	sqlite3_stmt* _tmp21_ = NULL;
	GraphMediaModelosSentimiento* _tmp22_ = NULL;
	const gchar* _tmp23_ = NULL;
	gchar* _tmp24_ = NULL;
	GDestroyNotify _tmp25_ = NULL;
	gint _tmp26_ = 0;
	gint _tmp27_ = 0;
	sqlite3_stmt* _tmp28_ = NULL;
	gint _tmp29_ = 0;
	gint _tmp30_ = 0;
	GraphMediaModelosSentimiento* _tmp31_ = NULL;
	sqlite3* _tmp32_ = NULL;
	gint64 _tmp33_ = 0LL;
	GraphMediaModelosSentimiento* _tmp34_ = NULL;
	GraphMediaModelosSentimiento* _tmp35_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (sentimiento != NULL, NULL);
	_tmp0_ = sentimiento;
	_tmp1_ = graph_media_modelos_sentimientos_existe_sentimiento (self, _tmp0_);
	if (_tmp1_) {
		GraphMediaModelosSentimiento* _tmp2_ = NULL;
		GraphMediaModelosSentimiento* _tmp3_ = NULL;
		_tmp2_ = sentimiento;
		_tmp3_ = _graph_media_modelos_sentimiento_ref0 (_tmp2_);
		result = _tmp3_;
		return result;
	}
	_tmp4_ = ((GraphMediaModelosTablas*) self)->nombre_tabla;
	_tmp5_ = g_strdup_printf ("INSERT INTO %s (nombre, descripcion) ", _tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = g_strconcat (_tmp6_, "VALUES (?, ?)", NULL);
	_tmp8_ = _tmp7_;
	_g_free0 (_tmp6_);
	sql = _tmp8_;
	_tmp9_ = graph_media_modelos_tablas_bd;
	_tmp10_ = sql;
	_tmp12_ = sqlite3_prepare_v2 (_tmp9_, _tmp10_, -1, &_tmp11_, NULL);
	_sqlite3_finalize0 (query);
	query = _tmp11_;
	res = _tmp12_;
	_tmp13_ = res;
	_vala_assert (_tmp13_ == SQLITE_OK, "res == Sqlite.OK");
	_tmp14_ = query;
	_tmp15_ = sentimiento;
	_tmp16_ = _tmp15_->nombre;
	_tmp17_ = g_strdup (_tmp16_);
	_tmp18_ = g_free;
	_tmp19_ = sqlite3_bind_text (_tmp14_, 1, _tmp17_, -1, _tmp18_);
	res = _tmp19_;
	_tmp20_ = res;
	_vala_assert (_tmp20_ == SQLITE_OK, "res == Sqlite.OK");
	_tmp21_ = query;
	_tmp22_ = sentimiento;
	_tmp23_ = _tmp22_->descripcion;
	_tmp24_ = g_strdup (_tmp23_);
	_tmp25_ = g_free;
	_tmp26_ = sqlite3_bind_text (_tmp21_, 2, _tmp24_, -1, _tmp25_);
	res = _tmp26_;
	_tmp27_ = res;
	_vala_assert (_tmp27_ == SQLITE_OK, "res == Sqlite.OK");
	_tmp28_ = query;
	_tmp29_ = sqlite3_step (_tmp28_);
	res = _tmp29_;
	_tmp30_ = res;
	if (_tmp30_ != SQLITE_DONE) {
		result = NULL;
		_g_free0 (sql);
		_sqlite3_finalize0 (query);
		return result;
	}
	_tmp31_ = sentimiento;
	_tmp32_ = graph_media_modelos_tablas_bd;
	_tmp33_ = sqlite3_last_insert_rowid (_tmp32_);
	_tmp31_->id = _tmp33_;
	_tmp34_ = sentimiento;
	_tmp35_ = _graph_media_modelos_sentimiento_ref0 (_tmp34_);
	result = _tmp35_;
	_g_free0 (sql);
	_sqlite3_finalize0 (query);
	return result;
}