Added client options used to send or show received chat with empty body.

git-svn-id: http://yate.null.ro/svn/yate/trunk@4676 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
marian 2011-11-04 10:27:05 +00:00
parent f606ceebb5
commit 24eb907c51
4 changed files with 37 additions and 9 deletions

View File

@ -206,7 +206,8 @@ String Client::s_toggles[OptCount] = {
"multilines", "autoanswer", "ringincoming", "ringoutgoing",
"activatelastoutcall", "activatelastincall", "activatecallonselect",
"display_keypad", "openincomingurl", "addaccountonstartup",
"dockedchat", "destroychat", "notifychatstate"
"dockedchat", "destroychat", "notifychatstate", "showemptychat",
"sendemptychat"
};
bool Client::s_engineStarted = false; // Engine started flag
bool Client::s_idleLogicsTick = false; // Call logics' timerTick()

View File

@ -6558,7 +6558,8 @@ bool DefaultLogic::defaultMsgHandler(Message& msg, int id, bool& stopLogic)
bool hasState = !delay && buildChatState(chatState,msg,c->m_name);
const String& body = msg[YSTRING("body")];
NamedList* p = 0;
if (body || !hasState)
if (body || (!hasState &&
Client::self()->getBoolOpt(Client::OptShowEmptyChat)))
p = buildChatParams(body,c->m_name,time,0 != delay,ds);
// Active state with no body or notification: remove last notification
// if the contact has a chat
@ -6636,7 +6637,8 @@ bool DefaultLogic::defaultMsgHandler(Message& msg, int id, bool& stopLogic)
String chatState;
bool hasState = !delay && buildChatState(chatState,msg,member->m_name);
NamedList* p = 0;
if (body || !hasState)
if (body || (!hasState &&
Client::self()->getBoolOpt(Client::OptShowEmptyChat)))
p = buildChatParams(body,member ? member->m_name : nick,time,0,0);
const String& id = mucChat ? room->resource().toString() : member->toString();
// Active state with no body or notification: remove last notification
@ -8082,14 +8084,16 @@ bool DefaultLogic::handleChatContactAction(const String& name, Window* wnd)
"DefaultLogic sending chat for contact=%s",c->toString().c_str());
String text;
c->getChatInput(text);
if (text && c->sendChat(text)) {
if ((text || Client::self()->getBoolOpt(Client::OptSendEmptyChat)) &&
c->sendChat(text)) {
unsigned int time = Time::secNow();
NamedList* tmp = buildChatParams(text,"me",time);
c->setChatProperty("history","_yate_tempitemreplace",String(false));
c->addChatHistory("chat_out",tmp);
c->setChatProperty("history","_yate_tempitemreplace",String(true));
c->setChatInput();
logChat(c,time,true,false,text);
if (text)
logChat(c,time,true,false,text);
}
}
else if (room) {
@ -8101,11 +8105,11 @@ bool DefaultLogic::handleChatContactAction(const String& name, Window* wnd)
room->uri().c_str(),m->m_name.c_str());
String text;
room->getChatInput(id,text);
bool ok = false;
bool ok = text || Client::self()->getBoolOpt(Client::OptSendEmptyChat);
if (room->ownMember(m))
ok = text && room->sendChat(text,String::empty(),"groupchat");
ok = ok && room->sendChat(text,String::empty(),"groupchat");
else
ok = text && room->sendChat(text,m->m_name);
ok = ok && room->sendChat(text,m->m_name);
if (ok) {
unsigned int time = Time::secNow();
NamedList* tmp = buildChatParams(text,"me",time);
@ -8113,7 +8117,8 @@ bool DefaultLogic::handleChatContactAction(const String& name, Window* wnd)
room->addChatHistory(id,"chat_out",tmp);
room->setChatProperty(id,"history","_yate_tempitemreplace",String(true));
room->setChatInput(id);
logChat(room,time,true,false,text,room->ownMember(m),m->m_name);
if (text)
logChat(room,time,true,false,text,room->ownMember(m),m->m_name);
}
}
else

View File

@ -180,6 +180,26 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="showemptychat" >
<property name="toolTip" >
<string>Show received chat with empty body</string>
</property>
<property name="text" >
<string>Show empty received chat</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="sendemptychat" >
<property name="toolTip" >
<string>Send empty chat</string>
</property>
<property name="text" >
<string>Send empty chat</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >

View File

@ -814,6 +814,8 @@ public:
OptDockedChat, // Show all contacts chat in the same window
OptDestroyChat, // Destroy contact chat when contact is removed/destroyed
OptNotifyChatState, // Notify chat states
OptShowEmptyChat, // Display received empty chat in chat history
OptSendEmptyChat, // Send empty chat
OptCount
};