11 time_t last_activity_time
;
12 enum connection_state_e connection_state
;
14 gchar
*eventstr(gchar
*str
) /* TODO const */
17 if (g_hash_table_lookup(config
, "events")) {
19 fd_events
= open(events_file
, O_WRONLY
| O_NONBLOCK
);
21 logf("open fd_events = %d errno = %d", fd_events
, errno
);
25 logf("Event: fd_events = %d, str = %s", fd_events
, str
);
27 if (fd_events
!= -1) {
28 write(fd_events
, str
, strlen(str
) + 1);
30 logf("write to fd_events = %d errno = %d", fd_events
, errno
);
38 inline void logs(const char *msg
, size_t len
)
40 g_array_append_vals(LogBuf
, msg
, len
);
43 gchar
* logstr(gchar
*msg
) /* TODO const */
47 g_printf("LOGF: %s", msg
);
54 void destroy_resource(resourceitem
*resi
)
57 if (resi
->name
) g_free(resi
->name
);
62 rosteritem
*addri(const gchar
*jid
, GHashTable
*resources
, unsigned type
)
66 logf("Adding %s to roster\n", jid
);
67 eventf("add_ri %s %s", jid
, (type
== MUC
) ? "MUC" : "BUDDY");
68 ri
= g_new(rosteritem
, 1);
70 ri
->jid
= g_strdup(jid
);
72 ri
->resources
= resources
; /* TODO */
74 ri
->resources
= g_hash_table_new_full(g_str_hash
, g_str_equal
, g_free
, (GDestroyNotify
) destroy_resource
);
75 ri
->log
= g_array_new(FALSE
, FALSE
, 1);
77 g_hash_table_insert(roster
, g_strdup(jid
), ri
);
78 ri
->self_resource
= g_new(resourceitem
, 1);
83 void destroy_ri(rosteritem
*RI
)
86 eventf("del_ri %s", RI
->jid
);
87 if (RI
->jid
) g_free(RI
->jid
);
88 if (RI
->resources
) g_hash_table_destroy(RI
->resources
);
89 if (RI
->log
) g_array_free(RI
->log
, TRUE
);
90 if (RI
->self_resource
) g_free(RI
->self_resource
);
94 void free_all() // trying to make a general cleanup
96 g_hash_table_destroy(roster
);
97 g_array_free(LogBuf
, TRUE
);
98 g_hash_table_destroy(config
);
103 config
= g_hash_table_new_full(g_str_hash
, g_str_equal
, NULL
, g_free
);
108 { "username", NULL
},
109 { "password", NULL
},
110 { "register", NULL
},
111 { "resource", "hatexmpp" },
115 { "muc_default_nick", "hatexmpp" },
116 { "jiv_name", NULL
},
118 { "jiv_version", NULL
},
119 { "send_receipts", "1" },
121 { "proxy_server", NULL
},
122 { "proxy_port", NULL
},
123 { "proxy_username", NULL
},
124 { "proxy_password", NULL
},
128 const struct cfg_s
*cfgp
= cfg
;
131 void *v
= cfgp
->value
? g_strdup(cfgp
->value
) : NULL
;
132 g_hash_table_insert(config
, cfgp
->name
, v
);
133 } while ((++cfgp
)->name
);
136 int main(int argc
, char **argv
)
138 if (!lm_ssl_is_supported()) {
139 fprintf(stderr
, "Your loudmouth distribution doesn't support SSL. hatexmpp won't work properly. Poke the author if you'd like to be able to run it in plaintext-only mode. Exiting.\n");
142 LogBuf
= g_array_sized_new(FALSE
, FALSE
, 1, 512);
143 logf("hatexmpp v%s is going up\n", HateXMPP_ver
);
144 roster
= g_hash_table_new_full(g_str_hash
, g_str_equal
, g_free
, (GDestroyNotify
) destroy_ri
);
145 context
= g_main_context_new();
146 main_loop
= g_main_loop_new(context
, FALSE
);
150 // Do something with this!!!!!
152 events_file
= g_strdup_printf("%sevents", argv
[1]);
155 logf("Events FIFO: %s\n", events_file
);
157 return fuseinit(argc
, argv
);