Logo Search packages:      
Sourcecode: gabber2 version File versions  Download package

void Gabber::PlainTextView::append ( const jabberoo::Message &  m,
const Glib::ustring &  nick,
bool  local_msg = false,
bool  seen = false 
) [virtual]

Append a complete message to the view. This will cancel a pending composing event.

Parameters:
m A reference to the message to add
nick The nickname to add it under
local_msg If this is from the local user or not
seen If this msg has already been seen by the user before

Implements Gabber::PrettyText.

Definition at line 144 of file PlainTextView.cc.

References cancel_composing(), Gabber::Util::DateTime, Gabber::TextBufferParser::parse_buffer(), and Gabber::Util::parse_timestamp().

{
    if (m.findX("jabber:x:delay") != NULL &&
        m.getBaseElement().hasAttrib("gabber:timestamp"))
    {
        update_timestamp(Util::parse_timestamp(
            m.getBaseElement().getAttrib("gabber:timestamp"), Util::DateTime));
    }
    else
    {
        update_timestamp(m.get_timestamp());
    }

    Glib::ustring from = m.getFrom();
    Glib::ustring tag = "local";

    if (!local_msg) 
    {
        if (_composers.find(from) != _composers.end())
            cancel_composing(from);

        tag = "remote";
    }

    _buffer->move_mark(_start_of_last_msg , _buffer->end());

    if (seen)
        tag += "_seen";

    Gtk::TextBuffer::iterator sit, eit;
    const Glib::ustring& body = m.getBody();
    // Check for /me
    if (body.substr(0,3) == "/me" && (body.substr(0,4) == "/me " || body.substr(0,6) == "/me's "))
    {
        std::string action_tag = seen ? "action_seen" : "action";
          // set the tags for /me
          std::vector<Glib::ustring> metags(2);
          metags[0] = action_tag;
          metags[1] = tag;

          // insert the /me text
          _buffer->insert_with_tags_by_name(_buffer->end(), "* ", metags);
            _buffer->insert_with_tag(_buffer->end(), nick, action_tag);
        _buffer->end();
          _buffer->insert_with_tag(_buffer->end(), 
                    body.substr(3) + "\n", action_tag);
    }
    else
    {
        // no /me, insert normally
        _buffer->insert_with_tag(_buffer->end(), "<", tag);
        if (seen)
            _buffer->insert_with_tag(_buffer->end(), nick, "seen");
        else
            _buffer->insert(_buffer->end(), nick);
        _buffer->move_mark(_startmark, 
                           _buffer->insert_with_tag(_buffer->end(), "> ", tag));
        if (seen)
            _buffer->insert_with_tag(_buffer->end(), body + "\n", "seen");
        else
            _buffer->insert(_buffer->end(), body + "\n");
        _buffer->move_mark(_bottom, _buffer->end());
    
        // URIs and smileys ahoy
        _bufferparser->parse_buffer(_startmark, _bottom);
    }

    _buffer->move_mark(_bottom, _buffer->end());

    if (local_msg || _goto_bottom) {
#ifdef OLD_GTKMM
      _view->scroll_to_mark(_bottom, 0, 0, 0);
#else
         _view->scroll_to(_bottom, 0);
#endif
    }
}


Generated by  Doxygen 1.6.0   Back to index