How to stay logged in on IRC forever?

You may have different reasons why you want to stay (always) connected to an IRC channel. Maybe you did a question and you are waiting for a response but you have other things to do and you want to shut your notebook down. Or maybe you are the maintainer of a program and you would like to see all the questions your users did during the last 24 hours.

Firstly, you will need a cloud service with Linux. Then you will have to install and set up ‘weechat’ and ‘tmux’.

Installing Weechat
Weechat is a text-based IRC client easy-to-use.

$ sudo apt-get install weechat

Installing tmux
tmux is a terminal multiplexer that allows you to have multiple terminal sessions to be accessed from a single screen. You can switch between these terminals.

$ sudo apt-get install weechat

After installing tmux and weechat, start a new tmux session. We will call to this session ircsession.

$ tmux new -s ircsession

Then you will open weechat.

$ weechat


In weechat, you can connect to the IRC server and channel you want. For example, let’s connect to #gstreamer in irc.freenode.net!

/set irc.server.freenode.nicks "your_nickname"
/connect freenode
/join #gstreamer

If you got an error about SASL, do this:

/set irc.server.freenode.sasl_username "your_nickname"
/set irc.server.freenode.sasl_password "xxxxxxx"

That’s it. You can close the terminal window when you want. if you want to see your IRC tmux session again later, type:

tmux attach -t ircsession

TIPS

  • “pg up” to scroll up.
  • “pg dn” to scroll down.
  • “F11” to scroll nicklist up.
  • “F12” to scroll nicklist down.

For more information, you can check the Weechat quick start guide.

Inside gobject_new

Sometimes when you do not have nothing to do, you can go to Netflix to watch your favorite movie, or you may read GObject source code. I have been reading how g_object_new works and I have decided to explain about it what I have understood so far.

First, we are going to remember the prototype and how we create a GObject.

This is the prototype of g_object_new:

gpointer
g_object_new (GType	   object_type,
	      const gchar *first_property_name,
	      ...)

So in order to create a GObject of the type G_TYPE_TEST we can just do something like:

GObject *my_object = g_object_new (G_TYPE_TEST, "dummy1", 100.0, "dummy2", 200, NULL);

This line creates a Detroit Red Wings jersey mens gobject setting the properties values of the property called “dummy1” to 100 and the value of the property called “dummy2” to 200. What does happen here?

When you defined the G_TYPE_TEST object, you had to define its properties. To do so you must have called g_object_class_install_property function.

  g_object_class_install_property (gobject_class,
				   PROP_DUMMY1,
				   g_param_spec_int ("dummy1",
						     NULL, 
						     NULL,
						     0, G_MAXINT, 0,
						     G_PARAM_CONSTRUCT | G_PARAM_READWRITE));

GObject has a “pool” of “properties” that are “ready to use”. What this piece of code do is to tell GObject that a property called “dummy1” that belongs to the class of G_TYPE_TEST should be added to the “pool”.

When you call g_object_new, it will set the values property per property. First it will lookup in the “pool” if the property “dummy1” exists for the class of G_TYPE_TEST. Then the following may happen:

  1. If the property does not exist (was not installed), a critical error should be shown:

    “%s: object class ‘%s’ has no property named ‘%s’”

  2. If the property is not writable (it has not the type G_PARAM_WRITE or G_PARAM_READWRITE set), then a critical error will be shown

    “%s: property ‘%s’ of object class ‘%s’ is not writable”

  3. If the property has been specified twice

    “%s: property ‘%s’ for type ‘%s’ cannot be set twice”

If whichever of the cases described above occur, the object will be created, but the rest of the properties will not be analyzed. However, if none of the above cases present, as this example is the case, g_object_new will internally create a GObjectConstructorParam which is just a structure:

struct _GObjectConstructParam
{
  GParamSpec *pspec;
  GValue     *value;
};

After creating this structure by setting the “pspec” to the parameter specification that was taken from the pool and setting tthe value to a new created GValue containing the value of 100 (in the example), this GObjectConstructParam will be put in an array. g_object_new has an array for each property (or parameter). g_object_new uses by default an array of size 16 which means that GObject sees more likely that GObject classes doesn’t have more than 16 properties, but if there cheap jerseys are more, it will increase the size of this array.

After populating the array for all the properties passed to g_object_new, properties are not set yet. When properties will start to be set (throughout an internal function called object_set_property), transformations between values will be set. So for example, you can pass a float value, but the property is defined as an integer, actually.

An internal function called g_object_new_internal will be called. First, this internal function will create an instance (using g_type_create_instance). Then only the construct properties will be set, in this case “dummy1” because it was defined with G_PARAM_CONSTRUCT. After construct properties have been set, the other properties will be set. Setting a property as was mentioned, involves a transformation between value types. But not only that, GObject keeps a notification queue ‘notify_queue’, so whenever a bunch of properties are set, this queue is locked in order to add the properties to this queue using the function g_object_notify_queue_add. After all the properties has been set, the queue is unlocked and the object is returned.