Exemplo n.º 1
0
  void BookmarkStorage::storeBookmarks( const BookmarkList& bList, const ConferenceList& cList )
  {
    Tag* s = new Tag( "storage" );
    s->addAttribute( XMLNS, XMLNS_BOOKMARKS );

    BookmarkList::const_iterator itb = bList.begin();
    for( ; itb != bList.end(); ++itb )
    {
      Tag* i = new Tag( s, "url", "name", (*itb).name );
      i->addAttribute( "url", (*itb).url );
    }

    ConferenceList::const_iterator itc = cList.begin();
    for( ; itc != cList.end(); ++itc )
    {
      Tag* i = new Tag( s, "conference", "name", (*itc).name );
      i->addAttribute( "jid", (*itc).jid );
      i->addAttribute( "autojoin", (*itc).autojoin ? "true" : "false" );

      new Tag( i, "nick", (*itc).nick );
      new Tag( i, "password", (*itc).password );
    }

    storeXML( s, this );
  }
Exemplo n.º 2
0
BookmarkList
ConvertToBookmarkList(const vector<String>& lst)
{
	BookmarkList bookmarks;

	bookmarks.reserve(lst.size());
	for(const auto& str : lst)
		bookmarks.push_back(stoul(str.GetMBCS()));
	return bookmarks;
}
Exemplo n.º 3
0
  void BookmarkStorage::handlePrivateXML( const Tag* xml )
  {
    if( !xml )
      return;

    BookmarkList bList;
    ConferenceList cList;
    const TagList& l = xml->children();
    TagList::const_iterator it = l.begin();
    for( ; it != l.end(); ++it )
    {
      if( (*it)->name() == "url" )
      {
        const std::string& url = (*it)->findAttribute( "url" );
        const std::string& name = (*it)->findAttribute( "name" );

        if( !url.empty() && !name.empty() )
        {
          BookmarkListItem item;
          item.url = url;
          item.name = name;
          bList.push_back( item );
        }
      }
      else if( (*it)->name() == "conference" )
      {
        const std::string& jid = (*it)->findAttribute( "jid" );
        const std::string& name = (*it)->findAttribute( "name" );

        if( !jid.empty() && !name.empty() )
        {
          const std::string& join = (*it)->findAttribute( "autojoin" );
          ConferenceListItem item;
          item.jid = jid;
          item.name = name;
          const Tag* nick = (*it)->findChild( "nick" );
          if( nick )
            item.nick = nick->cdata();
          const Tag* pwd = (*it)->findChild( "password" );
          if( pwd )
            item.password = pwd->cdata();
          item.autojoin = ( join == "true" || join == "1" );
          cList.push_back( item );
        }
      }
    }

    if( m_bookmarkHandler )
      m_bookmarkHandler->handleBookmarks( bList, cList );
  }
    virtual void handleBookmarks( const BookmarkList &bList, const ConferenceList &cList )
    {
      printf( "received bookmarks...\n" );

      BookmarkList::const_iterator it_b = bList.begin();
      for( ; it_b != bList.end(); it_b++ )
      {
        printf( "url: %s, name: %s\n", (*it_b).url.c_str(), (*it_b).name.c_str() );
      }
      ConferenceList::const_iterator it_c = cList.begin();
      for( ; it_c != cList.end(); it_c++ )
      {
        printf( "jid: %s, name: %s, nick: %s, pwd: %s\n", (*it_c).jid.c_str(), (*it_c).name.c_str(),
                (*it_c).nick.c_str(), (*it_c).password.c_str() );
      }

      BookmarkList mybList;
      ConferenceList mycList;

      BookmarkListItem bItem;
      bItem.url = "http://camaya.net/gloox";
      bItem.name = "gloox";
      mybList.push_back( bItem );

      bItem.url = "http://jabber.cc";
      bItem.name = "public jabber services";
      mybList.push_back( bItem );

      ConferenceListItem cItem;
      cItem.jid = "*****@*****.**";
      cItem.name = "jabber development";
      cItem.nick = "myNick";
      cItem.autojoin = false;
      mycList.push_back( cItem );

      cItem.jid = "*****@*****.**";
      cItem.name = "jabberd development";
      cItem.nick = "myOtherNick";
      cItem.password = "******";
      cItem.autojoin = true;
      mycList.push_back( cItem );

      b->storeBookmarks( mybList, mycList );
    }
Exemplo n.º 5
0
BookmarkList get_bookmarks(std::string query, std::string folder, int sort) {
    BookmarkList bookmarks;

    sqlite3 *db;
    sqlite3_stmt *stmt;
    std::string sql = "SELECT url, title, icon FROM bookmarks WHERE 1";
    if (query != "")
        sql += " AND (url LIKE '%' || ? || '%' OR title LIKE '%' || ?1 || '%')";
    if (folder != "")
        sql += " AND folderId = '" + folder + "'";
    if (sort == 0)
        sql += " ORDER BY length(title) > 0 DESC, title ASC";
    else
        sql += " ORDER BY created DESC";

    if (!run_statement(sql, &db, &stmt))
        goto exit;

    if (query != "") {
        if (sqlite3_bind_text(stmt, 1, query.data(), -1, SQLITE_STATIC)) {
            std::cerr << "Error binding text: " << sqlite3_errmsg(db) << std::endl;
            goto exit;
        }
    }

    {
        int res = sqlite3_step(stmt);
        while (res == SQLITE_ROW) {
            Bookmark b;
            b.url = sqlite3_column_string(stmt, 0, "");
            b.title = sqlite3_column_string(stmt, 1, b.url);
            b.icon = sqlite3_column_string(stmt, 2, "file:///usr/share/icons/suru/actions/scalable/stock_website.svg");
            bookmarks.emplace_back(b);
            res = sqlite3_step(stmt);
        }
        if (res != SQLITE_DONE) {
            std::cerr << "Error reading rows: " << sqlite3_errmsg(db) << std::endl;
        }
    }

    exit:
    sqlite3_close(db);
    return bookmarks;
}
Exemplo n.º 6
0
//! \since build 397
vector<String>
ConvertToUIString(const BookmarkList& lst, ShlTextReader& shl)
{
	vector<String> vec;

	vec.reserve(lst.size());
	for(const auto pos : lst)
		vec.push_back(ConvertToUIString(pos, shl));
	return vec;
}
Exemplo n.º 7
0
void ZhscWidget::modifyBookmark()
{
  BookmarkList dbml;
  BookmarkList b;
  dbml.clear();

  Bookmark bm;
  BookmarkList::Iterator it;

  BMDialog *dlg = new BMDialog( this, "bmdialog" );
  dlg->setBML( bml );

  if ( dlg->exec() == QDialog::Accepted ) 
  {
    b = dlg->deletedBML();
    for ( it = b.begin(); it != b.end(); ++it )
    {
      bm.dynastyno = (*it).dynastyno;
      bm.poetno = (*it).poetno;
      bm.poemno = (*it).poemno;
      bm.content = (*it).content;

      dbml.append( bm );
    }

    if ( bConStatus )
    {
      QString sq = "select * from bookmark";
      QSqlQuery query( sq );

      for ( it = dbml.begin(); it != dbml.end(); ++it )
      {
        sq = "delete from bookmark where dynastyno = '" + (*it).dynastyno + "' and poetno = '" + (*it).poetno + "' and poemno = '" + (*it).poemno + "'";
        query.exec( sq );
      }
    }

    bookmark();
  }

  delete dlg;
}