/* This file is part of Bolixo. Bolixo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Bolixo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Bolixo. If not, see . */ #include #include #include #include #include #include #include #include #include #include #include #define DEFINE_USERINFO #include "util.h" #include "../bolixo.h" #include "../bolixo.m" #include #define INSTRUMENT_EXTERN #include "../instrument.h" #include #include "webtabs.h" #include "w_var.h" #include "steps.h" #include "document.h" #include #include "../proto/bod_client.protoch" #include "../proto/bolixod_client.protodef" #include "../proto/bolixoapi.protoch" #include "../proto/webapi.protoch" W_SSTRING w_recipients2("recipients2"); // Allow override of w_recipients W_SSTRING w_replyid("replyid"); // Provide path to init content static int index_paste_copy (CONNECT_INFO &con, PARAM_STRING newfname) { glocal int ret = -1; // tlmp_error ("pasting %s %s -> %s\n",fcopy.path.c_str(),fcopy.date.c_str(),newfname.ptr); (con,w_session.c_str(),fcopy.path,fcopy.date,newfname); if (!success){ htmlprintf (MSG_U(E_CANTPASTEENTRY,"Can't paste: %s
\n"),msg); }else{ glocal.ret = 0; }
return glocal.ret; } void index_paste(CONNECT_INFO &con, PARAM_STRING path) { if (fcopy.path.size() == 0){ htmlout (MSG_U(E_NOTHINGTOPASTE,"Nothing to paste
\n")); }else{ glocal const char *path = path.ptr; glocal CONNECT_INFO *con = &con; glocal string newfname = string_f("%s/%s",path.ptr,fcopy.name.c_str()); ENTRY_TYPE type = util_entrytype(con,glocal.newfname); if (type != ENTRY_NONE){ ("pasterename"); Please select a new name. ?> /-

/- /-
htmlout (MSG_R(F_OLDNAME)); /- htmlout(fcopy.name); /-
htmlout (MSG_R(F_NEWNAME)); /- field_string (w_name,""); /-
bool ret = true; glocal.newfname = string_f("%s/%s",glocal.path,w_name.c_str()); if (util_entrytype(*glocal.con,glocal.newfname) != ENTRY_NONE){ htmlprintf (MSG_U(E_NAMEEXIST,"File or folder name %s already exist"),w_name.c_str()); ret = false; } return ret; if (index_paste_copy (*glocal.con,glocal.newfname)==-1){ fail = true; } }else{ index_paste_copy (con,glocal.newfname); } } } static void index_list_contacts(CONNECT_INFO &con, vector &contacts) { glocal contacts; (con,w_session.c_str(),""); for (auto m:members) glocal.contacts.push_back(m); } // Paste something into a message. // If the group is the inbox, we need a recipient. static void index_paste(CONNECT_INFO &con, PARAM_STRING path, PARAM_STRING groupowner, PARAM_STRING group, PARAM_STRING channel) { glocal con; if (fcopy.path.size()==0){ htmlprintf (MSG_R(E_NOTHINGTOPASTE),fcopy.path.c_str()); }else{ glocal vector recipients; glocal function fun; glocal.fun = [&](bool &fail){ glocal fail; fail = false; (con,w_session.c_str(),"",glocal.recipients,group,groupowner,fcopy.path,fcopy.date,""); if (!success){ glocal.fail = true; htmlprintf (MSG_R(E_CANTPASTEENTRY),msg); } }; if (is_eq(group,"inbox")){ if (is_eq(channel,"")){ ("recipients"); vector contacts; index_list_contacts (glocal.con,contacts); /-#I_RECIPIENTNEEDED Please provide one or more recipients for this message. /-

/- /-
htmlout (MSG_R(F_RECIPIENTS)); /- field_string (w_name,"",contacts); /-
auto tb = str_splitline(w_name.c_str()); for (auto &t:tb) glocal.recipients.push_back(t); bool ret = true; // bod_client_sendtalk_file validates the recipients if (glocal.recipients.size() == 0){ htmlprintf ("%s
\n",MSG_R(E_NORECIPIENT)); ret = false; } return ret;
glocal.fun(fail); }else{ glocal.recipients = str_splitline(channel,' '); bool fail; glocal.fun(fail); } }else{ bool fail; glocal.fun(fail); } } } // Set the MENU_PASTE menu, make it gray out sens void index_setpastemenu (_F_webtable *c, PARAM_STRING path) { bool disable = false; string paste = MSG_U(M_PASTE,"Paste"); if (fcopy.path.size()==0){ disable = true; // Nothing to paste }else{ #if 0 if (fcopy.path == path.ptr){ disable = true; // Pasting on itself }else{ size_t size = strlen(path.ptr); if (strncmp(fcopy.path.c_str(),path.ptr,size)==0){ // Check if copypath come from the directory path const char *pt = fcopy.path.c_str()+size; if (pt[0] == '/'){ pt = strchr(pt+1,'/'); if (pt == NULL){ // copypath is a file or folder member of path disable = true; } } } } #endif paste = string_f("%s %s",MSG_R(M_PASTE),fcopy.name.c_str()); } c->adddrop_opt (MENU_PASTE,paste); if (disable) c->setdrop_disable(MENU_PASTE); } /* Modify a text message and append a link "...more" or "...less" to let the user expand or contract the message. For message not truncated, it is used to allow just visual selection of the message. */ string append_more_less(PARAM_STRING uuid, bool truncated, string &content, _F_webtable &webtable, bool div_id, const char *style) { const char *msg = nullptr; if (truncated){ msg = MSG_U(I_DOT_MORE,"... more"); }else if (find(fulltext.begin(),fulltext.end(),uuid.ptr) != fulltext.end()){ msg = MSG_U(I_DOT_LESS,"... less"); }else{ if (div_id){ return string_f("

%s
\n" ,uuid.ptr,style,uuid.ptr,content.c_str()); }else{ return string_f("
%s
\n" ,style,uuid.ptr,content.c_str()); } } const char *br = (false && content.size() > 0 && content[content.size()-1] != '\n') ? "
\n" : ""; if (div_id){ return string_f("
%s
%s
%s
\n" ,uuid.ptr,style,uuid.ptr,content.c_str(),br,uuid.ptr,msg); }else{ return string_f("
%s
%s
%s
\n" ,style,uuid.ptr,content.c_str(),br,uuid.ptr,msg); } } string append_more_less(PARAM_STRING uuid, bool truncated, string &content, _F_webtable &webtable, bool div_id) { return append_more_less (uuid,truncated,content,webtable,div_id,"smsg"); } /* Return the color (row style in fact) to tell if this ID has a notification or not */ static const char *index_talk_notify_color (const string &id, const char *prefix) { const char *ret = "white"; string tmp = string(prefix) + ':' + id; if (userinfo.notifies.count(tmp) > 0){ ret = "orange"; } return ret; } static void index_talk_delnotify (CONNECT_INFO &con_sess, PARAM_STRING prefix, PARAM_STRING id) { util_delnotify (con_sess,prefix,id); bool talks_found = false; for (auto &s:userinfo.notifies){ if (is_start_any_of (s,NONEED,"talks:")) talks_found = true; } userinfo.talk_notify = talks_found; if (!talks_found){ /- } } static string index_findrecipients(const SHORTMSG_receive &m) { auto tb = str_splitline(m.recipients); string tmp; if (userinfo.name != m.from) tmp = m.from; for (auto &t:tb){ if (t != m.from && t != userinfo.name){ if (tmp.size() > 0) tmp += " "; tmp += t; } } return tmp; } static void index_download (CONNECT_INFO &con, FILE_TYPE file_type, PARAM_STRING fname) { string filename,extension; index_msg_name(file_type,filename,extension); tlmpweb_header ("Content-Disposition"," attachment; filename=%s.%s",filename.c_str(),extension.c_str()); util_sendfile (con,w_session.c_str(),fname); } /* Applies the quote reply formatting to the current message and place this in the form */ static void index_quotereply(const char *from, const char *content) { string tmp("> "); tmp += html_sprintf (MSG_U(I_WROTEBY,"%s wrote:\n"),from); tmp += content[0] == '>' ? ">" : "> "; tmp += copystring (content,[](auto &c, const char *pt){ if (*pt == '\n' && !is_any_of(pt[1],'\n','\0')){ if (pt[1] == '>'){ // This is an already quoted line, so "> bla bla" becomes ">> bla bla" c.replace(1,"\n>"); }else{ c.replace(1,"\n> "); } } }); tlmpweb_forcevar(w_content,tmp); } static void index_quotereply(const SHORTMSG_receive &m) { index_quotereply (m.from,m.content); } // If the channel is not empty, return /channel. static string msgs_unblank_channel(PARAM_STRING channel) { string ret; const char *pt = channel.ptr; if (pt != nullptr && *pt != '\0'){ ret = '/'; ret += pt; } return ret; } // Display a 2 columns table line. The second column may be a value or a clickable URL static void dir_row(const char *title, const char *value, bool format, bool href) { DIV tr; tr.tr().print(); DIV td1; td1.w(15).td().print(); htmlout (title); td1.end(); DIV td2; td2.td().print(); if (format){ }else if (href){ util_print_span(value); }else{ htmlout (value); } } // DIsplay a 4 columns table line static void dir_row4(const char *title1, PARAM_STRING value1, const char *title2, PARAM_STRING value2) { DIV tr; tr.tr().print(); DIV td; td.td().print(); htmlout (title1); td.td().print(); htmlout (value1); td.td().print(); htmlout (title2); td.td().print(); htmlout (value2); } template static void msgs_show_address(const T &info) { IMAGES_SIZE imgsizes; if (info.address1[0] != '\0' || info.address2[0] != '\0' || info.city[0] != '\0' || info.zipcode[0] != '\0' || info.state[0] != '\0' || info.country[0] != '\0' || info.phone[0] != '\0' || info.fax[0] != '\0'){ DIV dd; dd.bg("white").w(95).marginleftauto().marginrightauto().vmargins(5,5).paddings(5,5).borderradius(10).print(); { DIV txt; txt.w(100).textalign("center").fontsize(imgsizes.medium_font_size).print(); htmlprintf ("%s\n",MSG_R(F_ADDRESS1)); } DIV table; table.table().print(); if (info.address1[0] != '\0'){ DIV tr; tr.tr().print(); DIV td; td.td().print(); htmlprintf ("%s\n",info.address1); } if (info.address2[0] != '\0'){ DIV tr; tr.tr().print(); DIV td; td.td().print(); htmlprintf ("%s\n",info.address2); } { DIV tr; tr.tr().print(); DIV td; td.td().print(); htmlprintf ("%s, %s\n",info.city,info.state); } { DIV tr; tr.tr().print(); DIV td; td.td().print(); htmlprintf ("%s, %s\n",info.country,info.zipcode); } if (info.phone[0] != '\0'){ DIV tr; tr.tr().print(); DIV td; td.td().print(); htmlout (MSG_R(F_PHONE)); td.end(); td.td().print(); htmlprintf ("%s\n",info.phone); } if (info.fax[0] != '\0'){ DIV tr; tr.tr().print(); DIV td; td.td().print(); htmlout (MSG_R(F_FAX)); td.end(); td.td().print(); htmlprintf ("%s\n",info.fax); } } } enum class RELATION_STATUS { NONE, CONNECTED, // The relatin is established REJECTED, // The relation was refused by the peer REJECTED_BY_YOU,// The relation was refused by you WAITING, // The user has sent a request, but the peer has not responded WAITING_FOR_YOU // The user has received a connection request, but has not responded }; // What is the status of this user static RELATION_STATUS msgs_relation_status(CONNECT_INFO &con, PARAM_STRING user) { glocal RELATION_STATUS ret = RELATION_STATUS::NONE; glocal user; for (int i=0; i<2; i++){ glocal bool to_me = i == 1; (con,w_session.c_str(),"",i,glocal.user,0,100); //tlmp_warning ("contact user=%s size=%zu to_me=%d\n",glocal.user.ptr,contacts.size(),glocal.to_me); for (auto &c:contacts){ if (is_eq(glocal.user,c.user)){ if (c.status == CONTACT_ACCEPTED){ glocal.ret = RELATION_STATUS::CONNECTED; }else if (c.status == CONTACT_REJECTED){ glocal.ret = glocal.to_me ? RELATION_STATUS::REJECTED_BY_YOU : RELATION_STATUS::REJECTED; }else if (c.status == CONTACT_WAITING){ glocal.ret = glocal.to_me ? RELATION_STATUS::WAITING_FOR_YOU : RELATION_STATUS::WAITING; } break; } } } return glocal.ret; } static bool msgs_interest(CONNECT_INFO &con, PARAM_STRING user) { glocal user; glocal bool ret = false; (con,w_session.c_str(),""); if (success){ for (auto &u:users){ if (is_eq(u.name,glocal.user)){ glocal.ret = true; break; } } } return glocal.ret; } void msgs_showdirentry(CONNECT_INFO &con, PARAM_STRING user) { glocal const char *user = user.ptr; // glocal.user is either a local user (jack) or a remote (jack@some_server) glocal con; glocal CONNECT_HTTP_INFO dircon; glocal string fulluser; glocal string server; glocal string local_name; { // user.ptr may be a remote user (jack@some_server), or a local user (jack) or a fully qualified local user (jack@this_node) // we want fulluser to be the fully qualified // and glocal.user, to be either a local name or a remote user. const char *this_node = util_getnodename(); if (splitline(user,'@',glocal.local_name,glocal.server)){ glocal.fulluser = user.ptr; if (glocal.server == this_node){ glocal.user = glocal.local_name.c_str(); } }else{ glocal.local_name = user.ptr; glocal.fulluser = string_f("%s@%s",user.ptr,this_node); glocal.server = this_node; } } //tlmp_warning ("user.ptr=%s local.user=%s fulluser=%s\n",user.ptr,glocal.user,glocal.fulluser.c_str()); glocal.dircon.init(util_getdirserver()); glocal.dircon.setpageapi("bolixoapi"); //glocal.dircon.setnonstrictmode(); (glocal.dircon,glocal.fulluser,false); glocal bool user_has_msgs = false; // User has public messages or not // We can tell somewhat from the directory (public page) // but the user may have no entry in the directory, yet // have public messages. A little strange but possible. // So we check here glocal vector user_msgs; IMAGES_SIZE imgsizes; { CONNECT_HTTP_INFO webcon; // We initialize the webcon using what was returned by readuserinfo. // But if the user is not in the directory, we have to guess if (info.nodename[0] != '\0'){ webcon.init(info.nodename); }else{ // Here we guess it is using https string url = string_f("https://%s",glocal.server.c_str()); webcon.init(url); } (webcon,glocal.local_name,0,3); if (success){ glocal.user_has_msgs = true; for (auto &m:messages){ glocal.user_msgs.push_back(m); } } } DIV d("textgrow","showentry"); d.bg("#BFE4FF").w(100).h(100).autoscroll().print(); auto actions = [&](){ // Actions doable on this user DIV dd; dd.bg("white").w(95).marginleftauto().marginrightauto().vmargins(5,5).paddings(5,5).borderradius(10).print(); { DIV txt; txt.w(100).textalign("center").fontsize(imgsizes.medium_font_size).print(); /-#T_ACTIONS Actions } if (is_eq(userinfo.name,glocal.user)){ /-#I_NOACTIONONYOU No action on yourself }else{ DIV table; table.table().w(100).print(); { DIV td2; td2.td().paddings(20,0).textalign("left"); // Used in copy later, no print() DIV td3; td3.td().paddings(30,0).textalign("right"); // Used in copy later, no print() DIV tr; tr.tr().print(); { DIV td; td.td().print(); htmlprintf ("%s",MSG_R(T_CONTACTS)); } { DIV td; td.copy(td2).print(); auto status = msgs_relation_status(glocal.con,glocal.user); if (status == RELATION_STATUS::NONE){ htmlprintf (MSG_U(I_NOTCONNECTEDWITH,"Not connected with user %s"),glocal.user); td.copy(td3).print(); DIV msg("linkbutton"); msg.title(string_f(MSG_U(I_SENDCONTACTREQTO,"Send a contact request to %s"),glocal.user)); msg.params("onclick=formsubmit('/index.hc?webstep=%d&webtab_add=1:Contact-req~%s&webtab_add2=2:sendcontact~%s&recipients=%s')" ,step_profile,url_encode(MSG_R(T_CONTACT_REQS)).c_str() ,url_encode(MSG_R(I_CONTACTREQUEST)).c_str(),glocal.user); msg.print(); htmlprintf ("%s\n",MSG_R(I_SENDCONTACT)); }else if (status == RELATION_STATUS::CONNECTED){ /-#I_YOUARECONNECTED You are connected td.copy(td3).print(); DIV msg("linkbutton"); msg.title(string_f(MSG_U(I_SENDMSGTO,"Send a message to %s"),glocal.user)); msg.params("onclick=formsubmit('/index.hc?webstep=%d&webtab_add=1:%s:inbox/%s~%s')" ,step_talks,userinfo.name.c_str(),glocal.user,glocal.user); msg.print(); /-#I_SENDMESSAGE Send a message }else if (status == RELATION_STATUS::REJECTED){ htmlprintf (MSG_U(I_USERHASREJECTEDYOU,"%s has rejected your connection request"),glocal.user); }else if (status == RELATION_STATUS::REJECTED_BY_YOU){ htmlprintf (MSG_U(I_YOUREJECTEDUSER,"You rejected the connection request from %s"),glocal.user); }else if (status == RELATION_STATUS::WAITING){ htmlprintf (MSG_U(I_YOUSENTCONTACTREQ,"You sent a contact request to %s. Waiting"),glocal.user); }else if (status == RELATION_STATUS::WAITING_FOR_YOU){ htmlprintf (MSG_U(I_USERSENTREQUEST,"%s sent a contact request, waiting for your answer"),glocal.user); td.copy(td3).print(); DIV msg("linkbutton"); msg.title(MSG_U(I_MANAGECONTACTS,"Manage contacts")); msg.params("onclick=formsubmit('/index.hc?webstep=%d&webtab_add=1:Contacts~%s')" ,step_profile,MSG_R(T_CONTACT_REQS)); msg.print(); htmlout (MSG_R(I_MANAGECONTACTS)); } } tr.tr().print(); { DIV td; td.td().print(); htmlprintf ("%s",MSG_R(T_INTERESTS)); } { DIV td; td.copy(td2).print(); bool interest = msgs_interest(glocal.con,glocal.user); if (interest){ htmlprintf (MSG_U(I_YOUARESUBSCRIBED,"You are subscribed to %s"),glocal.user); td.copy(td3).print(); DIV msg("linkbutton"); msg.title(MSG_U(I_MANAGEINTERESTS,"Manage interests")); msg.params("onclick=formsubmit(\"/index.hc?webstep=%d&webtab_add=1:Interests~%s\")" ,step_profile,url_encode(MSG_R(T_INTERESTS)).c_str()); msg.print(); htmlout (MSG_R(I_MANAGEINTERESTS)); }else{ htmlprintf (MSG_U(I_YOUARENOTSUBSCRIBED,"You are not subscribed to %s"),glocal.user); td.copy(td3).print(); DIV msg("linkbutton"); msg.title(string_f(MSG_U(I_ADDINTERESTUSER,"Add interest for user %s"),glocal.user)); msg.params("onclick=formsubmit(\"/index.hc?webstep=%d&webtab_add=1:Interests~%s&webtab_add2=2:interest~%s&name=%s&list=%s\")" ,step_profile,url_encode(MSG_R(T_INTERESTS)).c_str() ,url_encode(MSG_R(I_NEWINTEREST)).c_str() ,glocal.user,MSG_R(I_0_NEWS)); msg.print(); htmlprintf (MSG_R(I_ADDINTERESTUSER),glocal.user); } } } } }; auto messages = [&](){ // Messages published by this user DIV dd; dd.bg("white").w(95).marginleftauto().marginrightauto().vmargins(5,5).paddings(5,5).borderradius(10).print(); { DIV txt; txt.w(100).textalign("center").fontsize(imgsizes.medium_font_size).print(); /-#I_PUBMESSAGES Public messages } glocal imgsizes; (WEBID("direntry")); no_autoscroll(); int rownum=0; for (auto &m:glocal.user_msgs){ setrow ("sep",rownum,"#%s\t%s",m.from.c_str(),util_format_shortmsg(m.content,glocal.imgsizes.image_width).c_str()); rownum++; } }; if (!success){ if (internal_error){ htmlprintf ("internal error %d msg=%s\n",internal_error,msg); }else{ { DIV dd; dd.bg("white").w(95).h(20).marginleftauto().marginrightauto().vmargins(10,5).paddings(5,5).borderradius(10) .textalign("center").print(); DIV ddd; ddd.h(100).vpaddings(20,0).fontsize(imgsizes.medium_font_size).print(); htmlprintf (MSG_U(E_NOPUBINFO,"No information about user %s in the public directory\n"),glocal.fulluser.c_str()); } actions(); messages(); } }else{ DIV dd; dd.bg("white").w(95).marginleftauto().marginrightauto().vmargins(10,5).paddings(5,5).borderradius(10).print(); { DIV ddd; ddd.w(100).dispflex().flowrow().print(); DIV img; img.flexfixe().marginleftauto().print(); if (info.mini_photo_modified[0] != '\0'){ htmlprintf ("\n" ,imgsizes.mini_photo_width,util_getdirserver(),info.user,info.nodename,info.mini_photo_modified); } img.end(); DIV txt; txt.flexfixe().vertalign("middle").fontsize_px(imgsizes.large_font_size).margins(5,0).marginrightauto().print(); htmlout (glocal.fulluser); } { // We put the large photo and multiple lines next to it. So we start with a flowrow() and the a flowcol() DIV row; row.w(100).dispflex().flowrow().print(); if (info.photo_modified[0] != '\0'){ DIV img; img.flexfixe().print(); htmlprintf ("\n" ,imgsizes.photo_width,util_getdirserver(),info.user,info.nodename,info.photo_modified); } DIV col; col.w(100).dispflex().flowcol().print(); { DIV one; one.flexfixe().margins(5,0).print(); htmlprintf ("%s\n" ,imgsizes.large_font_size,info.fullname); } { DIV one; one.flexfixe().margins(5,0).print(); htmlprintf ("%s %s\n",MSG_R(I_SINCE),format_date(userinfo.dateformat,info.created).c_str()); } if (info.email[0] != '\0'){ DIV one; one.flexfixe().margins(5,0).print(); htmlprintf ("%s %s\n",MSG_R(F_EMAIL),info.email); } if (info.city[0] != '\0'){ DIV one; one.flexfixe().margins(5,0).print(); htmlprintf ("%s\n",info.city); } { DIV one; one.flexfixe().paddings(5,5).margins(5,0).vmargins(5,0).borderradius(5).border(1,"lightgray").print(); html_r_printf ("%s\n",util_format_shortmsg(info.interest,imgsizes.image_width).c_str()); } } if (info.website[0] != '\0' || info.bolixosite[0] != '\0'){ /-

DIV site; site.w(100).table().print(); if (info.website[0] != '\0'){ dir_row (MSG_R(F_WEBSITE),info.website,false,true); } if (info.bolixosite[0] != '\0'){ dir_row (MSG_R(F_BOLIXOSITE),info.bolixosite,false,true); } } dd.end(); msgs_show_address(info); actions(); // Server information dd.bg("white").w(95).marginleftauto().marginrightauto().vmargins(5,5).paddings(5,5).borderradius(10).print(); { DIV ddd; ddd.w(100).dispflex().flowrow().print(); DIV txt; txt.flexfixe().vertalign("middle").fontsize_px(imgsizes.large_font_size).marginleftauto().marginrightauto().print(); htmlprintf ("%s %s\n",MSG_U(I_HOSTEDON,"Hosted on"),glocal.server.c_str()); } { // We put the large photo and multiple lines next to it. So we start with a flowrow() and the a flowcol() DIV row; row.w(100).dispflex().flowrow().print(); if (server.photo_modified[0] != '\0'){ DIV img; img.flexfixe().print(); htmlprintf ("\n" ,imgsizes.photo_width,util_getdirserver(),"",info.nodename,server.photo_modified); } DIV col; col.w(100).dispflex().flowcol().print(); { DIV one; one.flexfixe().margins(5,0).print(); htmlprintf ("%s %s\n",MSG_R(I_SINCE),format_date(userinfo.dateformat,server.created).c_str()); } if (server.email[0] != '\0'){ DIV one; one.flexfixe().margins(5,0).print(); htmlprintf ("%s %s\n",MSG_R(F_EMAIL),server.email); } if (server.city[0] != '\0'){ DIV one; one.flexfixe().margins(5,0).print(); htmlprintf ("%s\n",server.city); } { DIV one; one.flexfixe().paddings(5,5).margins(5,0).vmargins(5,0).borderradius(5).border(1,"lightgray").print(); html_r_printf ("%s\n",util_format_shortmsg(server.description,imgsizes.image_width).c_str()); } } /-

{ DIV site; site.w(100).table().print(); if (server.website[0] != '\0'){ dir_row (MSG_R(F_WEBSITE),server.website,false,true); } dir_row4 (MSG_U(I_DOMAIN,"domain"),server.domain.domain,MSG_U(I_CREATIONDATE,"Creation date"),server.domain.creation_date); dir_row4 ("","",MSG_U(I_UPDATEDDATE,"Updated date"),server.domain.updated_date); dir_row4 ("","",MSG_U(I_EXPIRYDATE,"Expiry date"),server.domain.expiry_date); dir_row4 ("","",MSG_U(I_REGISTRAR,"Registrar"),server.domain.registrar); } dd.end(); msgs_show_address(server); messages(); } } /* Add a tab to display the public card of a user. See "display user card" below */ void msgs_addtab_user (_F_webtabs &c, PARAM_STRING user) { const char *name = user.ptr; const char *pt = strchr(name,'@'); if (pt != nullptr) name = pt+1; c.addtab (string_f("2:user/%s",user.ptr),name); } /* Show the content of one message folder, either private messages or group messages */ static void index_show_shortmsg( CONNECT_INFO &con, CONNECT_INFO &con_sess, const char *id, _F_webtabs &webtabs, PARAM_STRING groupname, PARAM_STRING groupowner, PARAM_STRING channel, unsigned &offset, // First row displayed unsigned &nbhidden) // How many message are not shown { glocal id; glocal nbhidden; glocal webtabs; glocal con; glocal con_sess; glocal string groupname = groupname.ptr; glocal const char *groupowner = groupowner.ptr; glocal string path; WEBID ID_TALK("talk",string_f("%s:%s%s",groupowner.ptr,groupname.ptr,msgs_unblank_channel(channel).c_str())); glocal string table = ID_TALK.c_str(); glocal string channel = channel.ptr; glocal.path = string_f("/msgs/%s/short-inbox/%s",glocal.groupowner,glocal.groupname.c_str()); glocal bool is_inbox = glocal.groupname == "inbox"; glocal bool is_anonymous = glocal.groupname == "anonymous"; glocal IMAGES_SIZE imgsizes; offset = offsets[glocal.table]; (ID_TALK,currents[glocal.table],offset,5); auto common_start = [&](const char *name){ template_start (name); template_hori_layout(); template_add_button (MENU_QUOTEREPLY,"/reply.svg",MSG_R(M_QUOTEREPLY)); template_hori_space(); template_add_button (MENU_OPENINTAB,"/moveright.svg",MSG_R(M_OPENINTAB)); }; auto common_end = [&](){ template_hori_space(); template_add_dropmenu(); template_hori_space(); template_end(); }; common_start ("optnew"); //DIV d; d.w(100).textalign("right").border(1,"blue").dispflex().flowrow().print(); //{ DIV dd; dd.marginleftauto().print(); } template_hori_space(); template_add_button (MENU_MARKVIEWED,"/email-outline.svg",MSG_R(M_MARKVIEWED)); common_end(); common_start ("optv"); template_hori_space(); template_add_button (MENU_UNMARKVIEWED,"/email-open-outline.svg",MSG_R(M_MARKUNVIEWED)); common_end(); common_start ("optme"); common_end(); glocal unsigned dropmenu = dropmenu; if (butnum > 0) glocal.dropmenu = butnum; if (dropmenu == MENU_UNDELETE){ (glocal.con,w_session.c_str(),glocal.path); if (!success) htmlprintf (MSG_R(E_CANTUNDELETEENTRY),msg); }else if (dropmenu == MENU_PASTE){ index_paste (glocal.con,glocal.path,glocal.groupowner,glocal.groupname,glocal.channel); }else{ vector fullt; (glocal.con,w_session.c_str(),"",glocal.groupname,glocal.groupowner,fullt,noline,1,firstseens[glocal.table].last,glocal.channel); if (messages.size()!=1){ htmlprintf ("Internal error: %s\n",msg); }else{ auto &m = messages[0]; glocal string fname = string_f("%s/%s",glocal.path.c_str(),m.uuid); glocal const char *eventdate = m.eventdate; glocal string suggested_name; string filename,extension; index_msg_name (m.file_type,filename,extension); glocal.suggested_name = filename + "." + extension; if (glocal.dropmenu == MENU_DELETE){ (glocal.con,w_session.c_str(),glocal.fname); if (!success){ htmlprintf (MSG_R(E_CANTDELETEENTRY),msg); }else{ index_setcopyitem(glocal.con,glocal.con_sess,glocal.fname,glocal.eventdate,glocal.suggested_name); } }else if (glocal.dropmenu == MENU_COPY){ index_setcopyitem(glocal.con,glocal.con_sess,glocal.fname,glocal.eventdate,glocal.suggested_name); }else if (glocal.dropmenu == MENU_DOWNLOAD){ index_download (glocal.con,m.file_type,glocal.fname); }else if (glocal.dropmenu == MENU_REPLY){ string tmp = index_findrecipients(m); if (!glocal.is_anonymous && tmp.size() > 0){ tlmpweb_forcevar(w_recipients2,tmp); if (!glocal.is_inbox){ // When doing a private reply in a group, we defer to quote reply mode index_quotereply(m); glocal.webtabs.addtab (string_f("1:%s:inbox",userinfo.name.c_str()),MSG_U(I_SHORTINBOX,"Inbox")); } }else{ /-#E_REPLYTOYOU Can't reply to yourself } }else if (is_any_of(glocal.dropmenu,MENU_EDITITEM,MENU_QUOTEREPLY)){ if (m.file_type != FILE_TEXT){ /-#E_CANTEDIT Can't edit this message }else{ if (glocal.is_inbox) tlmpweb_forcevar(w_recipients2,index_findrecipients(m)); if (glocal.dropmenu == MENU_QUOTEREPLY){ index_quotereply(m); }else{ tlmpweb_forcevar(w_content,m.content); } } }else if (glocal.dropmenu == MENU_OPENINTAB){ const char *tabname = MSG_U(I_TEXT,"Text"); if (file_is_image(m.file_type)){ tabname = MSG_R(I_IMAGE); }else if (file_is_video(m.file_type)){ tabname = MSG_U(I_VIDEO,"Video"); }else if (file_is_sound(m.file_type)){ tabname = MSG_U(I_AUDIO,"Audio"); } glocal.webtabs.addtab (string_f("2:%s",glocal.fname.c_str()),tabname); }else if (glocal.dropmenu == MENU_MARKVIEWED){ util_markview (glocal.con,string_f("%s/%s",glocal.path.c_str(),m.uuid),true); }else if (glocal.dropmenu == MENU_UNMARKVIEWED){ util_markview (glocal.con,string_f("%s/%s",glocal.path.c_str(),m.uuid),false); }else if (glocal.dropmenu == MENU_USERINFO){ msgs_addtab_user (glocal.webtabs,m.from); }else if (glocal.dropmenu >= MENU_RECIPIENTINFO && glocal.dropmenu < MENU_RECIPIENTINFO + 10){ size_t recipient_num = glocal.dropmenu - MENU_RECIPIENTINFO; auto tb = str_splitline (m.recipients,' '); if (tb.size() > recipient_num){ msgs_addtab_user(glocal.webtabs,tb[recipient_num]); } }else if (m.file_type == FILE_PDF){ util_sendfile (glocal.con,w_session.c_str(),glocal.fname); }else if (file_is_video(m.file_type) || file_is_sound(m.file_type)){ tlmpweb_flushheader(); util_popup (glocal.con,m.content,m.file_type,m.submit,m.from ,string_f("/msgs/%s/short-inbox/%s/%s" ,glocal.groupowner,glocal.groupname.c_str(),m.uuid)); } } } glocal unsigned rownum = nbskip; // Defines all posible options for dropdown adddrop_opt (MENU_QUOTEREPLY,MSG_U(M_QUOTEREPLY,"Quoted reply")); if (!glocal.is_anonymous){ adddrop_opt (MENU_REPLY,glocal.is_inbox ? MSG_U(M_REPLY,"Reply") : MSG_U(M_PRIVATEREPLY,"Private reply")); } adddrop_opt (MENU_COPY,MSG_R(M_COPY)); index_setpastemenu(this,glocal.path); adddrop_opt (MENU_DELETE,MSG_R(M_DELETE)); adddrop_opt (MENU_UNDELETE,MSG_R(M_UNDELETE)); adddrop_opt (MENU_EDITITEM,MSG_U(M_EDIT,"Edit")); adddrop_opt (MENU_DOWNLOAD,MSG_R(M_DOWNLOAD)); adddrop_opt (MENU_OPENINTAB,MSG_U(M_OPENINTAB,"Open in tab")); adddrop_opt (MENU_USERINFO,MSG_U(M_USERINFO,"Display author info")); adddrop_opt (MENU_MARKVIEWED,MSG_U(M_MARKVIEWED,"mark as viewed")); adddrop_opt (MENU_UNMARKVIEWED,MSG_U(M_MARKUNVIEWED,"un mark as viewed")); index_msgs_style(*this); auto &fseen = firstseens[glocal.table]; const char *last = fseen.last.c_str(); if (w_showhidden == 1){ last = ""; setcurrent(0); } (glocal.con,w_session.c_str(),"",glocal.groupname,glocal.groupowner ,fulltext,nbskip,nblines,last,glocal.channel); glocal.webtable.setdrop_default({MENU_PASTE,MENU_UNDELETE}); const char *notify_name = glocal.is_inbox ? "talks" : "groups"; if (!success){ //htmlprintf ("Error: %s %s
",internal_error?"Internal error":"",msg); // No way to access, this is probably an old group or we are no more a member index_talk_delnotify (glocal.con_sess,notify_name,glocal.id); }else{ glocal.nbhidden = nbnew; glocal.webtable.settotal(total); glocal.webtable.sethiddens(nbnew); glocal.webtable.sethidden_title (tlmpweb_ismobile() ? MSG_U(I_NEWM,"new") : MSG_U(I_NEWMESSAGES,"new messages")); if (glocal.rownum == 0 && nbnew == 0 && messages.size() > 0){ web_update_firstseen(glocal.con_sess,glocal.table, messages[0].uuid); } if (nbnew == 0){ index_talk_delnotify (glocal.con_sess,notify_name,glocal.id); } string day; static const char *line_styles[]={"sep","sep1"}; unsigned line_style = 0; if (!deletes) glocal.webtable.setdrop_disable(MENU_UNDELETE); auto &previous_last = firstseens[glocal.table].previous; for (auto &m:messages){ bool from_me = is_eq(m.from,userinfo.name); const char *style_msg = from_me ? "smsgme" : "smsg"; if (from_me){ glocal.webtable.setdrop_disable(MENU_MARKVIEWED); glocal.webtable.setdrop_disable(MENU_UNMARKVIEWED); }else if (m.viewed){ glocal.webtable.setdrop_disable(MENU_MARKVIEWED); glocal.webtable.setdrop_enable(MENU_UNMARKVIEWED); }else{ glocal.webtable.setdrop_enable(MENU_MARKVIEWED); glocal.webtable.setdrop_disable(MENU_UNMARKVIEWED); } if (index_is_full_select(m.content,m.uuid)){ tlmpweb_ctrloutput (true); bool truncated; string form_content = util_format_shortmsg (m.content,m.uuid ,0,m.size,glocal.imgsizes.image_width,truncated); htmlout (append_more_less (m.uuid,truncated,form_content,glocal.webtable,false,style_msg)); tlmpweb_ctrloutput (false); glocal.webtable.setcurrent(glocal.rownum); return; } bool is_previous_last = previous_last == m.uuid; string now = string(m.submit,10); if (now != day){ day = now; glocal.webtable.setclickopt (true,"",""); glocal.webtable.setdrop_visibles({MENU_PASTE}); glocal.webtable.setrow(is_previous_last ? "yline" : "hline",-1,"

%s
\a\a\a",format_date(userinfo.dateformat,day).c_str()); glocal.webtable.resetdrop(); line_style=0; }else if (is_previous_last){ glocal.webtable.setclickopt (false,"",""); glocal.webtable.setrow("yline",-1,"
\a\a\a",is_mobile ? 15 : 5); } if (glocal.is_inbox){ if (userinfo.name == m.from){ glocal.webtable.setdrop_disable(MENU_REPLY); }else{ glocal.webtable.setdrop_enable(MENU_REPLY); } } if (m.file_type == FILE_TEXT){ glocal.webtable.setdrop_enable(MENU_EDITITEM); glocal.webtable.setdrop_enable(MENU_QUOTEREPLY); }else{ glocal.webtable.setdrop_disable(MENU_EDITITEM); glocal.webtable.setdrop_disable(MENU_QUOTEREPLY); } const char *style = line_styles[line_style]; line_style++; if (line_style == 2) line_style = 0; { // Print the first line of the message (from date) // The first line does not trigger the popup or display of the message. // It just makes the message current. const char *opt = "optme"; if (!from_me){ opt = m.viewed ? "optv" : "optnew"; } string time = string_f("
%s
" "%s
" ,format_date(userinfo.dateformat,m.submit).c_str() ,glocal.webtable.template_get_apply(opt).c_str()); string img; if (strcmp(m.from,"admin")==0){ // admin is not in the contact list of everyone, but has a public page img = ""; }else{ string dir = string_f("/projects/%s/public",m.from); img = util_mini_img(step_image,glocal.imgsizes.mini_photo_width,dir,"mini-photo.jpg",""); } glocal.webtable.setclickopt (true,"",""); glocal.webtable.setrow (style,glocal.rownum,"#
%s
\t
%s
\t%s" ,MENU_USERINFO,img.c_str(),MENU_USERINFO,m.from,time.c_str()); } const char *func = "Popup"; string path = string_f("/msgs/%s/short-inbox/%s/%s",glocal.groupowner,glocal.groupname.c_str(),m.uuid); if (glocal.webtabs.selected(WEBTAB_TYPE1,path)) glocal.webtable.setcurrent(glocal.rownum); if (file_is_sound(m.file_type)){ glocal.webtable.setclickopt (true,func,"400,100"); }else if (file_is_video(m.file_type)){ glocal.webtable.setclickopt (true,func,"800,800"); }else if (file_is_image(m.file_type)){ glocal.webtable.setclickopt (true,"",string_f("webtab_add=2:%s~%s",path.c_str(),MSG_U(I_IMAGE,"Image"))); }else if (file_is_text(m.file_type)){ //if (!is_mobile) glocal.webtable.setclickopt (true,"",string_f("fullt=%s",m.uuid)); }else if (m.file_type == FILE_PDF){ glocal.webtable.setclickopt (true,"viewintab",""); } string content; if (m.content[0] != '\0'){ bool truncated; string form_content = util_format_shortmsg (m.content,m.uuid ,0,m.size,glocal.imgsizes.image_width,truncated); content = append_more_less (m.uuid,truncated,form_content,glocal.webtable,true,style_msg); }else if (file_is_sound(m.file_type)){ string tmp = util_flipspaces(m.submit); content = string_f("" ,tlmpweb_curpage(),step_image,path.c_str(),tmp.c_str(),tbftype[m.file_type]); }else if (file_is_image(m.file_type)){ content = util_img (step_image,glocal.imgsizes.image_width,"",path,m.submit); }else if (file_is_video(m.file_type)){ string tmp = util_flipspaces(m.submit); const char *extension = util_video_extension(m.file_type); content = string_f( "" ,glocal.imgsizes.video_size,glocal.imgsizes.video_size ,tlmpweb_curpage(),step_image,path.c_str(),tmp.c_str(),extension); }else if (file_is_text(m.file_type)){ // Large text file (glocal.con,w_session.c_str(),path,"",true); if (!success){ htmlprintf (MSG_U(E_CANTREADFILE,"Can't read file: %s\n"),msg); }else{ string tmp = string((const char*)content.getbuffer(),content.getsize()); tmp = util_format_shortmsg (tmp.c_str(),0,info.size,glocal.imgsizes.image_width); glocal.webtable.setrow("image",glocal.rownum,"#\t%s\a",tmp.c_str()); } }else if (file_is_data(m.file_type)){ const char *image = "zip.png"; if (m.file_type == FILE_PDF) image = "pdf.png"; content = string_f(" %s" ,glocal.imgsizes.mini_photo_width,glocal.imgsizes.mini_photo_width,image,MSG_U(I_DATAFILE,"data files")); } if (m.recipients[0] != '\0'){ auto tb = str_splitline (m.recipients,' '); string tmp; int pos=0; for (auto &t:tb){ if (t != userinfo.name){ string add = string_f("%s",MENU_RECIPIENTINFO+pos,t.c_str()); tmp += " " + add; } pos++; } if (tmp.size() > 0){ glocal.webtable.setrow ("septo",glocal.rownum,"#%s\t%s\a",MSG_U(I_TO,"To:"),tmp.c_str()); } } glocal.webtable.setrow (style,glocal.rownum,"#\t%s\a",content.c_str()); glocal.rownum++; } }
}
// Convert a table of string into a single string using space as a separator static string msgs_tb2channel(vector &tb) { sort (tb.begin(),tb.end()); string ret; for (auto &t:tb){ if (ret.size() > 0) ret += ' '; ret += t; } return ret; } void bolixo_msgs( bool private_messages, // Are we showing private messages or groups CONNECT_INFO &con, CONNECT_INFO &con_sess, _F_websteps &websteps, vector &docpointers) { glocal private_messages; glocal con; glocal con_sess; glocal docpointers; static unsigned size[5]={15,40,45,0,0}; static unsigned size_mobile[5]={25,60,15,0,0}; (private_messages ? "talks" : "groups" ,tabs,is_mobile ? size_mobile : size); sethelp(); static WEBID id("tab:talk"); index_menu_top (glocal.private_messages ? sel_talk : sel_groups); (id,currents[id.c_str()]); if (glocal.private_messages && noline == 1){ glocal string error; glocal vector contacts; index_list_contacts(glocal.con,glocal.contacts); ("addchannel"); glocal.webtable.set_errortitle (MSG_U(T_ADDMSGCHANNEL,"Add a conversation")); /-#I_ADDMSGCHANNEL Enter a list of recipients for this new conversation. field_string(w_name,"style=width:100%",glocal.contacts); /-
util_format_error (true,glocal.error); /-
glocal bool ret = false; auto tb = str_splitline(w_name.c_str(),' '); if (tb.size() == 0){ glocal.error = MSG_U(E_ONERECIPIENTNEEDED,"Enter at least one recipients"); }else{ bool allok = true; for (auto &s:tb){ if (find(glocal.contacts.begin(),glocal.contacts.end(),s)==glocal.contacts.end()){ allok = false; glocal.error = string_f (MSG_U(E_UNKNOWNCONTACT,"Unknown recipients: %s"),s.c_str()); break; } } if (allok){ glocal string channel = msgs_tb2channel(tb); (glocal.con,w_session.c_str(),"","inbox",userinfo.name); if (!success){ glocal.error = msg; }else{ glocal.ret = true; for (auto &c:channels){ if (glocal.channel == c.name){ glocal.ret = false; glocal.error = MSG_U(E_CONVERSATIONEXIST,"This conversation already exists"); break; } } } } } return glocal.ret; glocal fail; auto tb = str_splitline(w_name.c_str(),' '); glocal string channel = msgs_tb2channel(tb); (glocal.con,w_session.c_str(),"","inbox",glocal.channel,""); if (!success){ glocal.error = msg; glocal.fail = true; }else{ // Create a tab to edit messages in this new conversation glocal.webtabs.addtab(string_f("1:%s:inbox/%s",userinfo.name.c_str(),glocal.channel.c_str()),glocal.channel); glocal.webtabs.commit_addtab(); }
}else if (dropmenu == MENU_NOTIFICATIONS){ glocal vector keys; if (glocal.private_messages){ glocal.keys.push_back(string_f("talks:%s:inbox",userinfo.name.c_str())); }else{ (glocal.con,w_session.c_str(),"",false); for (auto &g:groups){ if (userinfo.name != g.owner || is_not_in(g.name,"inbox","anonymous")){ glocal.keys.push_back(string_f("talks:%s:%s",g.owner,g.name)); } } glocal.keys.push_back(string_f("talks:%s:anonymous",userinfo.name.c_str())); } if (noline < glocal.keys.size()){ glocal const char *key = glocal.keys[noline].c_str(); ("notifications"); (glocal.con,w_session.c_str(),"",glocal.key); if (success){ w_notify_ui = ui; w_notify_active_ui = active_ui; w_notify_mobile_ui = active_mobile_ui; w_notify_email = email; } // active_ui and digest are not done, even if they are in the database // and the procotol set/get_notification supports it. glocal.webtable.set_errortitle(MSG_R(I_NOTIFICATIONS)); /- /-
/-#F_PASSIVENOTIFY Minimal UI notifications /- field_checkbox (w_notify_ui,""); /-
/-#F_ACTIVENOTIFY Active UI notifications /- field_checkbox (w_notify_active_ui,""); /-
/-#F_ACTIVEMOBILENOTIFY Active mobile UI notifications /- field_checkbox (w_notify_mobile_ui,""); /-
/-#F_EMAILNOTIFY Email notification /- field_checkbox (w_notify_email,""); /-
button_submit(); /-
return true; (glocal.con,w_session.c_str(),"" ,glocal.key,w_notify_ui,w_notify_active_ui,w_notify_mobile_ui,w_notify_email,false);
} }
util_add_dropmenu(*this); adddrop_opt(MENU_NOTIFICATIONS,MSG_U(M_NOTIFICATIONS,"Notifications")); if (glocal.private_messages){ const char *username = userinfo.name.c_str(); unsigned rownum = 0; string id = string_f("%s:inbox",username); string add = string_f("webtab_add=1:%s:inbox~%s",username,MSG_R(I_PRIVATEMSGS)); if (glocal.webtabs.selected(WEBTAB_TYPE1,id)) setcurrent(rownum); setclickopt (true,"",add); setid(string_f("talktbl:%s:inbox",username)); setrow (index_talk_notify_color(id,"talks"),rownum,"%s\a\t\bmenu\b" ,MSG_U(I_PRIVATEMSGS,"All messages")); setdrop_hidden (MENU_NOTIFICATIONS); rownum++; setclickopt (true,"",""); setrow ("white",rownum,"%s\a\t ",MSG_U(I_ADDCHANNEL,"+ Add")); (glocal.con,w_session.c_str(),"","inbox",username); const char *username = userinfo.name.c_str(); unsigned rownum = 2; for (auto &c:channels){ const char *channel = c.name; string encoded_channel = msgs_unblank_channel(channel); string id = string_f("%s:inbox%s",username,encoded_channel.c_str()); string add = string_f("webtab_add=1:%s:inbox%s~%s",username,encoded_channel.c_str(),channel); if (glocal.webtabs.selected(WEBTAB_TYPE1,id)) glocal.webtable.setcurrent(rownum); glocal.webtable.setclickopt (true,"",add); glocal.webtable.setid(string_f("talktbl:%s:inbox%s",username,encoded_channel.c_str())); glocal.webtable.setrow (index_talk_notify_color(id,"talks"),rownum,"  %s\a\t ",channel); rownum++; } }else{ sethead (MSG_U(H_TALKS,"Owner\tGroup\t ")); (glocal.con,w_session.c_str(),"",false); const char *username = userinfo.name.c_str(); unsigned rownum = 0; for (auto &g:groups){ if (userinfo.name != g.owner || is_not_in(g.name,"inbox","anonymous")){ string id = string_f("%s:%s",g.owner,g.name); string add = string_f("webtab_add=1:%s:%s",g.owner,g.name); if (glocal.webtabs.selected(WEBTAB_TYPE1,id)) glocal.webtable.setcurrent(rownum); glocal.webtable.setclickopt (true,"",add); glocal.webtable.setid (string_f("talktbl:%s:%s",g.owner,g.name)); glocal.webtable.setrow (index_talk_notify_color(id,"groups"),rownum,"%s\t%s\t\bmenu\b" ,g.owner,g.name); rownum++; } } string id = string_f("%s:anonymous",username); string add = string_f("webtab_add=1:%s:anonymous~%s",username,MSG_U(I_ANONINBOX,"Public-inbox")); if (glocal.webtabs.selected(WEBTAB_TYPE1,id)) glocal.webtable.setcurrent(rownum); glocal.webtable.setclickopt (true,"",add); glocal.webtable.setid(string_f("talktbl:%s:anonymous",username)); glocal.webtable.setrow (index_talk_notify_color(id,"groups"),rownum++,"\t%s\t\bmenu\b" ,MSG_R(I_ANONINBOX)); }
index_menu_bottom (sel_talk,nullptr);
vector tb; int n = str_splitline (id,':',tb); if (n != 2) return; glocal id; glocal string groupowner = tb[0]; glocal string groupname; glocal const char *formid = formid; glocal unsigned offset = 0; // First row displayed glocal unsigned nbhidden = 0; // Number of hidden message (not yet seen by the user) glocal string channel; if (!splitline (tb[1],'/',glocal.groupname,glocal.channel)){ glocal.groupname = tb[1]; }else{ //glocal.channel = msgs_blank_channel(glocal.channel); } (); if (glocal.groupname != "anonymous"){ glocal bool private_inbox = glocal.groupname == "inbox"; DIV f; f.id(TAB_FORM).bg("#a0a0a0").paddings(5,5).vpaddings(5,5).vmargins(5,0).borderradius(5).print(); (glocal.formid); DIV d; d.dispflex().flowcol().print(); const unsigned vspace=tlmpweb_ismobile() ? 10: 3; const unsigned hspace=3; glocal vector contacts; index_list_contacts(glocal.con,glocal.contacts); if (glocal.private_inbox && w_recipients2.size() > 0){ if (w_recipients.size() > 0){ string tmp = string_f("%s %s",w_recipients.c_str(),w_recipients2.c_str()); tlmpweb_forcevar(w_recipients,tmp); }else{ tlmpweb_forcevar(w_recipients,w_recipients2.c_str()); } } if (w_replyid.size() > 0){ (glocal.con,w_session.c_str(),w_replyid.c_str(),""); index_quotereply(w_recipients2.c_str(),content); } if (glocal.private_inbox && glocal.channel.size() == 0){ DIV dd; dd.w(100).flexfixe().vmargins(vspace,0).print(); DIV ddd; ddd.dispflex().flowrow().print(); DIV dddd; dddd.flexfixe().margins(0,hspace).print(); /-#F_RECIPIENTS Recipients dddd.end(); dddd.flexgrow().print(); field_string(w_recipients,"style=width:100%",glocal.contacts); } { DIV dd; d.w(100).flexfixe().vmargins(vspace,vspace).print(); // Limit message to 20000. The limit in the database is 64k. // But the limit for the paquet size used to communicate between // Bolixo components has been set to 64k. string place = string_f("placeholder='%s' maxlength=20000",MSG_U(I_WRITEMSG,"Write a message")); WEBID id ("talkedit",glocal.formid); field_textarea (w_content,id,8,-100,place.c_str()); } { DIV dd; dd.w(100).flexfixe().vmargins(5,0).print(); DIV ddd; ddd.dispflex().flowrow().print(); DIV dddd; dddd.flexfixe().print(); field_file_attach (w_upload); dddd.end(); dddd.flexfixe().marginleftauto().print(); button_send (); } if (!glocal.private_inbox){ DIV dd; dd.w(100).flexfixe().vmargins(vspace,0).print(); DIV ddd; ddd.dispflex().flowrow().print(); DIV dddd; dddd.flexfixe().margins(0,hspace).print(); /-#F_EXTRARECIPIENTS Recipients(opt) dddd.end(); dddd.flexgrow().print(); field_string(w_recipients,"style=width:100%",glocal.contacts); } bool ret = true; if (glocal.private_inbox && glocal.channel.size() == 0 && w_recipients.size()==0){ /-#E_ONERECIPIENT You must specify at least one recipient ret = false; }else{ string errmsg; util_format_shortmsg (w_content.c_str(),10,1000,100,true,glocal.con,errmsg); if (errmsg.size() > 0){ htmlout (errmsg); ret = false; } } return ret; glocal bool fail = false; glocal vector recipients; if (glocal.channel.size() > 0){ str_splitline(glocal.channel,' ',glocal.recipients); }else{ str_splitline(w_recipients.c_str(),' ',glocal.recipients); } if (w_content.size() > 0){ BOB_TYPE bob; bob.setbuffer (w_content.c_str(),w_content.size(),false); (glocal.con,w_session.c_str(),"",glocal.recipients ,glocal.groupname,glocal.groupowner,bob,false,"","","",""); if (!success){ htmlprintf (MSG_U(E_CANTSEND,"Can't send: %s
\n"),msg); glocal.fail = true; }
} if (strcmp(w_upload.c_str(),"")!=0){ const char *tempname = tlmpweb_getfilename(w_upload); struct stat64 st; if (stat64(tempname,&st)==-1 || st.st_size==0){ htmlprintf (MSG_U(E_EMPTYFILE,"Attached file is empty
")); glocal.fail = true; }else{ ("",tempname,glocal.fail); (glocal.con,w_session.c_str(),"",glocal.recipients ,glocal.groupname,glocal.groupowner ,content,more,"","","",""); glocal.sendfile.sethandle (handle); glocal.sendfile.setresult (success,msg); (glocal.con,w_session.c_str(),handle,content,more); glocal.sendfile.setresult (success,msg); } } fail = glocal.fail; if (!fail){ w_recipients.setempty(); w_content.setempty(); w_upload.setempty(); if (glocal.nbhidden == 0 && glocal.offset == 0) w_showhidden = 1; glocal.webflip.reload_second(); } keepediting = true;
}
index_show_shortmsg (glocal.con,glocal.con_sess,glocal.id,glocal.webtabs,glocal.groupname,glocal.groupowner,glocal.channel,glocal.offset,glocal.nbhidden);
if (w_fulltext.isset() || w_select.isset()) return; // We skip everything here during a partial fetch string user; if (strcmp(id,"help")==0){ DIV d("webtable"); d.print(); index_doc(glocal.docpointers[SECTION_TALK],section_talk); }else if (strcmp(id,"helpmain")==0){ DIV d("webtable"); d.print(); index_doc(glocal.docpointers[SECTION_NONE],section_none); }else if (splitline(id,'/',match("user"),user)){ // display public user card msgs_showdirentry(glocal.con,user); }else{ index_display_doc (glocal.con,id); }
}