Skip to content

Commit

Permalink
Core(refactor): use new sui interface
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverRainZ committed Dec 18, 2017
1 parent b9b9c4f commit 7dc04ed
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/core/chat.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,12 @@ static void add_message(Chat *chat, Message *msg);
static bool whether_merge_last_message(Chat *chat, Message *msg);

Chat *chat_new(Server *srv, const char *name){
bool ischan;
SrnRet ret;
Chat *chat;
SuiSessionFlag flag;

g_return_val_if_fail(name, NULL);

ischan = sirc_is_chan(name);
chat = g_malloc0(sizeof(Chat));

chat->joined = FALSE;
Expand All @@ -63,22 +61,22 @@ Chat *chat_new(Server *srv, const char *name){
ERR_FR("Read sui prefs failed: %s", RET_MSG(ret));
}

flag = ischan ? SUI_SESSION_CHANNEL : SUI_SESSION_DIALOG;
if (strcmp(META_SERVER, name) == 0){
flag = SUI_SESSION_SERVER;
}

flag = 0;
chat->ui = sui_new_session(&ui_events, chat->ui_prefs, flag);

if (!chat->ui){
goto cleanup;
}

sui_set_ctx(chat->ui, chat);
sui_start_session(chat->ui, name, srv->prefs->name);

/* For a dialog, its user_list must have yourself and the dialogue target */
if (flag == SUI_SESSION_DIALOG){
if (strcmp(META_SERVER, name) == 0){
sui_server_session(chat->ui, srv->prefs->name);
// Server
} else if (sirc_is_chan(name)){
// Channel
sui_channel_session(chat->ui, srv->chat->ui, name);
} else {
// Private, its user_list must have yourself and the dialogue target
sui_private_session(chat->ui, srv->chat->ui, name);
chat_add_user(chat, srv->user->nick, USER_CHIGUA);
chat_add_user(chat, name, USER_CHIGUA);
}
Expand Down

0 comments on commit 7dc04ed

Please sign in to comment.