Ejemplo n.º 1
0
 Notebook::Ptr NotebookManager::prompt_create_new_notebook(Gtk::Window *parent,
                                                           const Note::List & notesToAdd)
 {
   // Prompt the user for the name of a new notebook
   CreateNotebookDialog dialog(parent,
                               (GtkDialogFlags)(GTK_DIALOG_MODAL
                                                | GTK_DIALOG_DESTROY_WITH_PARENT));
   
   
   int response = dialog.run ();
   std::string notebookName = dialog.get_notebook_name();
   if (response != Gtk::RESPONSE_OK)
     return Notebook::Ptr();
   
   Notebook::Ptr notebook = obj().get_or_create_notebook (notebookName);
   if (!notebook) {
     DBG_OUT ("Could not create notebook: %s", notebookName.c_str());
   } 
   else {
     DBG_OUT ("Created the notebook: %s (%s)", notebook->get_name().c_str(),
              notebook->get_normalized_name().c_str());
     
     if (!notesToAdd.empty()) {
       // Move all the specified notesToAdd into the new notebook
       for(Note::List::const_iterator iter = notesToAdd.begin();
           iter != notesToAdd.end(); ++iter) {
         obj().move_note_to_notebook (*iter, notebook);
       }
     }
   }
   
   return notebook;
 }
Ejemplo n.º 2
0
bool TomboyImportAddin::first_run(mnote::NoteManager & manager)
{
  int to_import = 0;
  int imported = 0;
  bool success;

  DBG_OUT("import path is %s", m_tomboy_path.c_str());

  if(sharp::directory_exists(m_tomboy_path)) {
    std::list<std::string> files;
    sharp::directory_get_files_with_ext(m_tomboy_path, ".note", files);

    for(std::list<std::string>::const_iterator iter = files.begin();
        iter != files.end(); ++iter) {
      const std::string & file_path(*iter);

      to_import++;

      Note::Ptr note = manager.import_note(file_path);

      if(note) {
        DBG_OUT("success");
        success = true;
        imported++;
      }
    }
  }

  return success;
}
Ejemplo n.º 3
0
void getPasvParams( void )
{
	BYTE val;			// value
	BYTE vsave;
	char buf[4];		// item buffer ( one decimal number)
	BYTE pos = 0; 		// pos in item buffer
	BYTE nCommas = 0;	// Counter for commas
	BYTE c;

/*	
	// First read past result code
	// that is find first space	
	while( TCPGet( lftpsocket, &c ) ) {
		if ( ' ' == c ) {
			break;
		}
	}
	
	// Look for first digit
	while( TCPGet( lftpsocket, &c ) ) {
		if ( isdigit( c ) ) {
			break;
		}
	}		
	
	buf[ pos++ ] = c;
*/
	// Look for third comma
	while( TCPGet( ftpsocket, &c ) ) {
		DBG_OUT( c );
		if ( ',' == c ) {
			nCommas++;
			if ( nCommas >= 4 ) break;
		}
	}		
	
	DBG_OUT( '[' );
	while( TCPGet( ftpsocket, &c ) ) {
		DBG_OUT( c );
		if ( isdigit( c ) ) {
			buf[ pos++ ] = c;
		}
		else if ( 0x2c == c  ) {
			
			buf[ pos ] = 0;
			vsave = atoi( buf );	// save until last 	
			pos = 0;
	
		}
		else {
			// end char
			buf[ pos ] = 0;
			val = atoi( buf );
			portdata = ( ( ( unsigned int)vsave ) * 256 ) + val;
			DBG_OUT( ']' );
			break;
		}
	}
}
void NoteDirectoryWatcherApplicationAddin::delete_note(const Glib::ustring & note_id)
{
  DBG_OUT("NoteDirectoryWatcher: deleting %s because file deleted.", note_id.c_str());

  Glib::ustring note_uri = make_uri(note_id);

  gnote::NoteBase::Ptr note_to_delete = note_manager().find_by_uri(note_uri);
  if(note_to_delete != 0) {
    note_manager().delete_note(note_to_delete);
  }
  else {
    DBG_OUT("notedirectorywatcher: did not delete %s because note not found.", note_id.c_str());
  }
}
Ejemplo n.º 5
0
  void NoteEditor::update_custom_font_setting()
  {
    Glib::RefPtr<Gio::Settings> settings = Preferences::obj()
      .get_schema_settings(Preferences::SCHEMA_GNOTE);

    if (settings->get_boolean(Preferences::ENABLE_CUSTOM_FONT)) {
      std::string fontString = settings->get_string(Preferences::CUSTOM_FONT_FACE);
      DBG_OUT( "Switching note font to '%s'...", fontString.c_str());
      modify_font_from_string (fontString);
    } 
    else {
      DBG_OUT("Switching back to the default font");
      override_font (get_gnome_document_font_description());
    }
  }
Ejemplo n.º 6
0
  std::string SyncUtils::find_first_executable_in_path(const std::vector<std::string> & executableNames)
  {
    for(std::vector<std::string>::const_iterator iter = executableNames.begin();
        iter != executableNames.end(); ++iter) {
      std::string pathVar = Glib::getenv("PATH");
      std::vector<std::string> paths;
      const char separator[] = {G_SEARCHPATH_SEPARATOR, 0};
      sharp::string_split(paths, pathVar, separator);

      for(unsigned i = 0; i < sizeof(common_paths) / sizeof(char*); ++i) {
        std::string commonPath = common_paths[i];
        if(std::find(paths.begin(), paths.end(), commonPath) == paths.end()) {
          paths.push_back(commonPath);
        }
      }

      for(std::vector<std::string>::iterator path = paths.begin(); path != paths.end(); ++path) {
        std::string testExecutablePath = Glib::build_filename(*path, *iter);
        if(sharp::file_exists(testExecutablePath)) {
          return testExecutablePath;
        }
      }
      DBG_OUT("Unable to locate '%s' in your PATH", iter->c_str());
    }

    return "";
  }
Ejemplo n.º 7
0
void NiepceWindow::on_action_edit_labels()
{
    DBG_OUT("edit labels");
    // get the labels.
    EditLabels::Ptr dlg(new EditLabels(getLibraryClient()));
    dlg->run_modal(shared_frame_ptr());
}
Ejemplo n.º 8
0
std::string NiepceWindow::prompt_open_library()
{
    std::string libMoniker;
    Gtk::FileChooserDialog dialog(gtkWindow(), _("Open catalog"),
                                  Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER);
    dialog.add_button(_("Cancel"), Gtk::RESPONSE_CANCEL);
    dialog.add_button(_("Open"), Gtk::RESPONSE_OK);

    int result = dialog.run();
    Glib::ustring libraryToCreate;
    switch(result)
    {
    case Gtk::RESPONSE_OK: {
        Configuration & cfg = Application::app()->config();
        libraryToCreate = dialog.get_filename();
        // pass it to the library
        libMoniker = "local:";
        libMoniker += libraryToCreate.c_str();
        cfg.setValue("last_open_catalog", libMoniker);
        DBG_OUT("created catalog %s", libMoniker.c_str());
        break;
    }
    default:
        break;
    }
    return libMoniker;
}
Ejemplo n.º 9
0
void NiepceWindow::on_open_library()
{
    Configuration & cfg = Application::app()->config();
    std::string libMoniker;
    int reopen = 0;
    try {
        reopen = std::stoi(cfg.getValue("reopen_last_catalog", "0"));
    }
    catch(...)
    {
    }
    if(reopen) {
        libMoniker = cfg.getValue("last_open_catalog", "");
    }
    if(libMoniker.empty()) {
        libMoniker = prompt_open_library();
    }
    else {
        DBG_OUT("last library is %s", libMoniker.c_str());
    }
    if(!libMoniker.empty()) {
        if(!open_library(libMoniker)) {
            ERR_OUT("library %s cannot be open. Prompting.",
                    libMoniker.c_str());
            libMoniker = prompt_open_library();
            open_library(libMoniker);
        }
    }
}
Ejemplo n.º 10
0
  void AddinManager::load_addins_for_note(const Note::Ptr & note)
  {
    if(m_note_addins.find(note) != m_note_addins.end()) {
      ERR_OUT(_("Trying to load addins when they are already loaded"));
      return;
    }
    IdAddinMap loaded_addins;
    m_note_addins[note] = loaded_addins;

    IdAddinMap & loaded(m_note_addins[note]); // avoid copying the whole map
    for(IdInfoMap::const_iterator iter = m_note_addin_infos.begin();
        iter != m_note_addin_infos.end(); ++iter) {

      const IdInfoMap::value_type & addin_info(*iter); 
      sharp::IInterface* iface = (*addin_info.second)();
      NoteAddin * addin = dynamic_cast<NoteAddin *>(iface);
      if(addin) {
        addin->initialize(note);
        loaded.insert(std::make_pair(addin_info.first, addin));
      }
      else {
        DBG_OUT("wrong type for the interface: %s", typeid(*iface).name());
        delete iface;
      }
    }
  }
Ejemplo n.º 11
0
void NoteOfTheDay::cleanup_old(gnote::NoteManager & manager)
{
  gnote::Note::List kill_list;
  const gnote::Note::List & notes = manager.get_notes();

  Glib::Date date;
  date.set_time_current(); // time set to 00:00:00

  for (gnote::Note::List::const_iterator iter = notes.begin();
       notes.end() != iter; iter++) {
    const std::string & title = (*iter)->get_title();
    const sharp::DateTime & date_time = (*iter)->create_date();

    if (true == Glib::str_has_prefix(title, s_title_prefix)
        && s_template_title != title
        && Glib::Date(
             date_time.day(),
             static_cast<Glib::Date::Month>(date_time.month()),
             date_time.year()) != date
        && !has_changed(*iter)) {
      kill_list.push_back(*iter);
    }
  }

  for (gnote::Note::List::const_iterator iter = kill_list.begin();
       kill_list.end() != iter; iter++) {
    DBG_OUT("NoteOfTheDay: Deleting old unmodified '%s'",
            (*iter)->get_title().c_str());
    manager.delete_note(*iter);
  }
}
Ejemplo n.º 12
0
void WebDavSyncServiceAddin::save_config_settings(const Glib::ustring & url, const Glib::ustring & username, const Glib::ustring & password)
{
  // Save configuration into the GNOME Keyring and GSettings
  try {
    Glib::RefPtr<Gio::Settings> settings = Preferences::obj()
      .get_schema_settings(Preferences::SCHEMA_SYNC_WDFS);
    settings->set_string(Preferences::SYNC_FUSE_WDFS_USERNAME, username);
    settings->set_string(Preferences::SYNC_FUSE_WDFS_URL, url);

    if(password != "") {
      Ring::create_password(Ring::default_keyring(), KEYRING_ITEM_NAME, s_request_attributes, password);
    }
    else {
      Ring::clear_password(s_request_attributes);
    }
  }
  catch(KeyringException & ke) {
    DBG_OUT("Saving configuration to the GNOME keyring failed with the following message: %s", ke.what());
    // TODO: If the above fails (no keyring daemon), save all but password
    //       to GConf, and notify user.
    // Save configuration into GConf
    //Preferences.Set ("/apps/tomboy/sync_wdfs_url", url ?? string.Empty);
    //Preferences.Set ("/apps/tomboy/sync_wdfs_username", username ?? string.Empty);

    Glib::ustring msg = Glib::ustring::compose(
      // TRANSLATORS: %1 is the format placeholder for the error message.
      _("Saving configuration to the GNOME keyring failed with the following message:\n\n%1"),
      ke.what());
    throw gnote::sync::GnoteSyncException(msg.c_str());
  }
}
Ejemplo n.º 13
0
 void BugzillaNoteAddin::on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, 
                                               int x, int y, 
                                               const Gtk::SelectionData & selection_data, 
                                               guint, guint time)
 {
   DBG_OUT("Bugzilla.OnDragDataReceived");
   drop_uri_list(context, x, y, selection_data, time);
   return;
 }
Ejemplo n.º 14
0
bool GridViewModule::on_librarylistview_click(GdkEventButton *e)
{
    double x, y;
    int bx, by;
    bx = by = 0;
    x = e->x;
    y = e->y;
    Gtk::TreeModel::Path path;
    Gtk::CellRenderer * renderer = nullptr;
    DBG_OUT("click (%f, %f)", x, y);
    m_librarylistview->convert_widget_to_bin_window_coords(x, y, bx, by);
    if(m_librarylistview->get_item_at_pos(bx, by, path, renderer)){
        DBG_OUT("found an item");

        return true;
    }
    return false;
}
Ejemplo n.º 15
0
  void PrintNotesNoteAddin::on_begin_print(const Glib::RefPtr<Gtk::PrintContext>& context)
  {
    m_timestamp_footer = create_layout_for_timestamp(context);
    // Create and initialize the page margins
    m_margin_top = cm_to_pixel (1.5, context->get_dpi_y());
    m_margin_left = cm_to_pixel (1, context->get_dpi_x());
    m_margin_right = cm_to_pixel (1, context->get_dpi_x());
    m_margin_bottom = 0;
    double max_height = pango_units_from_double(context->get_height()
                                                - m_margin_top - m_margin_bottom
                                                - compute_footer_height(context));

    DBG_OUT("margins = %d %d %d %d", m_margin_top, m_margin_left,
            m_margin_right, m_margin_bottom);

    m_page_breaks.clear();

    Gtk::TextIter position;
    Gtk::TextIter end_iter;
    get_buffer()->get_bounds (position, end_iter);

    double page_height = 0;
    bool done = position.compare (end_iter) >= 0;
    while (!done) {
      Gtk::TextIter line_end = position;
      if (!line_end.ends_line ()) {
        line_end.forward_to_line_end ();
      }

      int paragraph_number = position.get_line();
      int indentation = 0;
      Glib::RefPtr<Pango::Layout> layout = create_layout_for_paragraph(
        context, position, line_end, indentation);

      Pango::Rectangle ink_rect;
      Pango::Rectangle logical_rect;
      for(int line_in_paragraph = 0;  line_in_paragraph < layout->get_line_count();
          line_in_paragraph++) {
        Glib::RefPtr<Pango::LayoutLine> line = layout->get_line(line_in_paragraph);
        line->get_extents (ink_rect, logical_rect);

        if ((page_height + logical_rect.get_height()) >= max_height) {
          PageBreak(paragraph_number, line_in_paragraph);
          m_page_breaks.push_back (PageBreak(paragraph_number, line_in_paragraph));
          page_height = 0;
        }

        page_height += logical_rect.get_height();

      }
      position.forward_line ();
      done = position.compare (end_iter) >= 0;
    }

    m_print_op->set_n_pages(m_page_breaks.size() + 1);
  }
void NoteDirectoryWatcherApplicationAddin::handle_file_system_change_event(
  const Glib::RefPtr<Gio::File> & file, const Glib::RefPtr<Gio::File> &, Gio::FileMonitorEvent event_type)
{
  switch(event_type) {
  case Gio::FILE_MONITOR_EVENT_CHANGED:
  case Gio::FILE_MONITOR_EVENT_DELETED:
  case Gio::FILE_MONITOR_EVENT_CREATED:
  case Gio::FILE_MONITOR_EVENT_MOVED:
    break;
  default:
    return;
  }

  Glib::ustring note_id = get_id(file->get_path());

  DBG_OUT("NoteDirectoryWatcher: %s has %d (note_id=%s)", file->get_path().c_str(), int(event_type), note_id.c_str());

  // Record that the file has been added/changed/deleted.  Adds/changes trump
  // deletes.  Record the date.
  m_lock.lock();
  try {
    auto record = m_file_change_records.find(note_id);
    if(record == m_file_change_records.end()) {
      m_file_change_records[note_id] = NoteFileChangeRecord();
      record = m_file_change_records.find(note_id);
    }

    if(event_type == Gio::FILE_MONITOR_EVENT_CHANGED) {
      record->second.changed = true;
      record->second.deleted = false;
    }
    else if(event_type == Gio::FILE_MONITOR_EVENT_CREATED) {
      record->second.changed = true;
      record->second.deleted = false;
    }
    else if(event_type == Gio::FILE_MONITOR_EVENT_MOVED) {
      record->second.changed = true;
      record->second.deleted = false;
    }
    else if(event_type == Gio::FILE_MONITOR_EVENT_DELETED) {
      if(!record->second.changed) {
	record->second.deleted = true;
      }
    }

    record->second.last_change = sharp::DateTime::now();
  }
  catch(...)
  {}
  m_lock.unlock();

  Glib::RefPtr<Glib::TimeoutSource> timeout = Glib::TimeoutSource::create(m_check_interval * 1000);
  timeout->connect(sigc::mem_fun(*this, &NoteDirectoryWatcherApplicationAddin::handle_timeout));
  timeout->attach();
}
Ejemplo n.º 17
0
Configuration::Configuration(const Glib::ustring & file)
    : m_filename(file)
    , m_root("main")
{
    try {
        m_keyfile.load_from_file(m_filename);
    }
    catch(...) {
        DBG_OUT("conf file %s not found - will be created", m_filename.c_str());
    }
}
Ejemplo n.º 18
0
bool DirectoryImporter::get_previews_for(const std::string& /*source*/,
                                         const std::list<std::string>& paths,
                                         const PreviewReady& callback)
{
    for (auto path : paths) {
        DBG_OUT("path %s", path.c_str());
        auto thumbnail = fwk::Thumbnail::thumbnail_file(path, 160, 160, 0);
        callback(path, thumbnail);
    }
    return true;
}
Ejemplo n.º 19
0
void writeRomString2Socket( ROM char* p ) 
{
	BYTE c;

   	while( ( c = *p++ ) ) {
		TCPPut( ftpsocket, c );
		DBG_OUT( c );
   	}
   	
   	TCPFlush( ftpsocket );
}
bool NoteDirectoryWatcherApplicationAddin::handle_timeout()
{
  m_lock.lock();
  try {
    std::vector<Glib::ustring> keysToRemove(m_file_change_records.size());

    for(auto iter : m_file_change_records) {
      DBG_OUT("NoteDirectoryWatcher: Handling (timeout) %s", iter.first.c_str());

      // Check that Note.Saved event didn't occur within (check-interval -2) seconds of last write
      if(m_note_save_times.find(iter.first) != m_note_save_times.end() &&
          std::abs((m_note_save_times[iter.first] - iter.second.last_change).total_seconds()) <= (m_check_interval - 2)) {
        DBG_OUT("NoteDirectoryWatcher: Ignoring (timeout) because it was probably a Gnote write");
        keysToRemove.push_back(iter.first);
        continue;
      }
      // TODO: Take some actions to clear note_save_times? Not a large structure...

      sharp::DateTime last_change(iter.second.last_change);
      if(sharp::DateTime::now() > last_change.add_seconds(4)) {
        if(iter.second.deleted) {
          delete_note(iter.first);
        }
        else {
          add_or_update_note(iter.first);
        }

        keysToRemove.push_back(iter.first);
      }
    }

    for(auto note_id : keysToRemove) {
      m_file_change_records.erase(note_id);
    }
  }
  catch(...)
  {}
  m_lock.unlock();

  return false;
}
Ejemplo n.º 21
0
void GridViewModule::select_image(eng::library_id_t id)
{
    DBG_OUT("library select %Ld", (long long)id);
    Gtk::TreePath path = m_model->get_path_from_id(id);
    if(path) {
        m_librarylistview->scroll_to_path(path, false, 0, 0);
        m_librarylistview->select_path(path);
    }
    else {
        m_librarylistview->unselect_all();
    }
}
Ejemplo n.º 22
0
eng::library_id_t GridViewModule::get_selected()
{
    eng::library_id_t id = 0;
    Glib::RefPtr<Gtk::TreeSelection> selection;

    std::vector<Gtk::TreePath> paths = m_librarylistview->get_selected_items();
    if(!paths.empty()) {
        Gtk::TreePath path(*(paths.begin()));
        DBG_OUT("found path %s", path.to_string().c_str());
        Gtk::TreeRow row = *(m_model->get_iter(path));
        if(row) {
            DBG_OUT("found row");
            eng::LibFile::Ptr libfile = row[m_model->columns().m_libfile];
            if(libfile) {
                id = libfile->id();
            }
        }
    }
    DBG_OUT("get_selected %Ld", (long long)id);
    return id;
}
Ejemplo n.º 23
0
void FilmStripController::select_image(eng::library_id_t id)
{
    DBG_OUT("filmstrip select %Ld", (long long)id);
    Gtk::TreePath path = m_store->get_path_from_id(id);
    if(path) {
        m_thumbview->scroll_to_path(path, false, 0, 0);
        m_thumbview->select_path(path);
    }
    else {
        m_thumbview->unselect_all();
    }
}
Ejemplo n.º 24
0
 Glib::RefPtr<Gtk::Action> ActionManager::find_action_by_name(const std::string & n) const
 {
   Glib::ListHandle<Glib::RefPtr<Gtk::Action> > actions = m_main_window_actions->get_actions();
   for(Glib::ListHandle<Glib::RefPtr<Gtk::Action> >::const_iterator iter2(actions.begin()); 
       iter2 != actions.end(); ++iter2) {
     if((*iter2)->get_name() == n) {
       return *iter2;
     }
   }
   DBG_OUT("%s not found", n.c_str());
   return Glib::RefPtr<Gtk::Action>();      
 }
Ejemplo n.º 25
0
bool WebDavSyncServiceAddin::verify_configuration()
{
  Glib::ustring url, username, password;

  if(!get_pref_widget_settings(url, username, password)) {
    // TODO: Figure out a way to send the error back to the client
    DBG_OUT("One of url, username, or password was empty");
    throw gnote::sync::GnoteSyncException(_("URL, username, or password field is empty."));
  }

  return true;
}
Ejemplo n.º 26
0
 void open_url(const std::string & url)
   throw (Glib::Error)
 {
   if(!url.empty()) {
     GError *err = NULL;
     DBG_OUT("Opening url '%s'...", url.c_str());
     gtk_show_uri (NULL, url.c_str(), GDK_CURRENT_TIME, &err);
     if(err) {
       throw Glib::Error(err, true);
     }
   }
 }
Ejemplo n.º 27
0
void
GridViewModule::on_lib_notification(const eng::LibNotification &ln)
{
    switch(ln.type) {
    case eng::Library::NotifyType::METADATA_QUERIED:
    {
        DBG_ASSERT(ln.param.type() == typeid(eng::LibMetadata::Ptr),
                   "incorrect data type for the notification");
        eng::LibMetadata::Ptr lm
            = boost::any_cast<eng::LibMetadata::Ptr>(ln.param);
        DBG_OUT("received metadata");
        m_metapanecontroller->display(lm->id(), lm);
        break;
    }
    case eng::Library::NotifyType::METADATA_CHANGED:
    {
        DBG_OUT("metadata changed");
        DBG_ASSERT(ln.param.type() == typeid(eng::metadata_desc_t),
                   "incorrect data type for the notification");
        eng::metadata_desc_t m = boost::any_cast<eng::metadata_desc_t>(ln.param);
        if(m.id == m_metapanecontroller->displayed_file()) {
            // FIXME: actually just update the metadata
          m_shell.getLibraryClient()->requestMetadata(m.id);
        }
        break;
    }
    case eng::Library::NotifyType::FILE_MOVED:
    {
        DBG_ASSERT(ln.param.type() == typeid(std::pair<eng::library_id_t,eng::library_id_t>),
                   "incorrect data type for the notification");
        std::pair<eng::library_id_t,eng::library_id_t> moved(boost::any_cast<std::pair<eng::library_id_t,eng::library_id_t> >(ln.param));

// check that the file that was moved still match the content

        break;
    }
    default:
        break;
    }
}
Ejemplo n.º 28
0
  /// <summary>
  /// Get all widgets represents by XML elements that are children
  /// of the placeholder element specified by path.
  /// </summary>
  /// <param name="path">
  /// A <see cref="System.String"/> representing the path to
  /// the placeholder of interest.
  /// </param>
  /// <returns>
  /// A <see cref="IList`1"/> of Gtk.Widget objects corresponding
  /// to the XML child elements of the placeholder element.
  /// </returns>
  void ActionManager::get_placeholder_children(const std::string & path, 
                                               std::list<Gtk::Widget*> & children) const
  {
    // Wrap the UIManager XML in a root element
    // so that it's real parseable XML.
    std::string xml = "<root>" + m_ui->get_ui() + "</root>";

    xmlDocPtr doc = xmlParseDoc((const xmlChar*)xml.c_str());
    if(doc == NULL) {
      return;
    }
        
    // Get the element name
    std::string placeholderName = sharp::string_substring(path, sharp::string_last_index_of(
                                                            path, "/") + 1);
    DBG_OUT("path = %s placeholdername = %s", path.c_str(), placeholderName.c_str());

    sharp::XmlNodeSet nodes = sharp::xml_node_xpath_find(xmlDocGetRootElement(doc), 
                                                         "//placeholder");
    // Find the placeholder specified in the path
    for(sharp::XmlNodeSet::const_iterator iter = nodes.begin();
        iter != nodes.end(); ++iter) {
      xmlNodePtr placeholderNode = *iter;

      if (placeholderNode->type == XML_ELEMENT_NODE) {

        xmlChar * prop = xmlGetProp(placeholderNode, (const xmlChar*)"name");
        if(!prop) {
          continue;
        }
        if(xmlStrEqual(prop, (const xmlChar*)placeholderName.c_str())) {

          // Return each child element's widget
          for(xmlNodePtr widgetNode = placeholderNode->children;
              widgetNode; widgetNode = widgetNode->next) {

            if(widgetNode->type == XML_ELEMENT_NODE) {

              xmlChar * widgetName = xmlGetProp(widgetNode, (const xmlChar*)"name");
              if(widgetName) {
                children.push_back(get_widget(path + "/"
                                              + (const char*)widgetName));
                xmlFree(widgetName);
              }
            }
          }
        }
        xmlFree(prop);
      }
    }
    xmlFreeDoc(doc);
  }
Ejemplo n.º 29
0
 void SilentUI::note_conflict_detected(NoteManager & manager,
                                       const Note::Ptr & localConflictNote,
                                       NoteUpdate remoteNote,
                                       const std::list<std::string> &)
 {
   DBG_OUT("note conflict detected, overwriting without a care");
   // TODO: At least respect conflict prefs
   // TODO: Implement more useful conflict handling
   if(localConflictNote->id() != remoteNote.m_uuid) {
     manager.delete_note(localConflictNote);
   }
   SyncManager::obj().resolve_conflict(OVERWRITE_EXISTING);
 }
Ejemplo n.º 30
0
void* receive_thread(void *arg)
{
	struct receive_param rcv_para = *((struct receive_param *)arg);
	PMIFI_PACKET packet, resp;
	u8 sum;
	int len;
	const int buff_len = 1024;
	
	packet = (PMIFI_PACKET)malloc(buff_len);
	resp = (PMIFI_PACKET)malloc(buff_len);
	memset(packet, 0x0, buff_len);

	while (read_packet(rcv_para.sd, packet) != ERROR) {
		DBG_OUT("Process received packet");

		len = get_packet_len(packet);
		sum = get_checksum((u8*)packet, len - 1);
		DBG_OUT("len = %d, recv sum = 0x%02x, calc sum = 0x%02x", len, ((u8*)packet)[len - 1], sum);
		dump_packet(packet);
        if (((u8*)packet)[len - 1] != sum)
            DBG_OUT("*** check sum fail");

        if (is_client_response(packet->func) == 0) {
			handle_packet(rcv_para.sd, packet);
			len = server_build_response(packet, resp);
			DBG_OUT("build response len is %d", len);
			if (len > 0) {
				DBG_OUT("enqueue packet to queue");
				push_data(rcv_para.sd, (u8*)resp, len);
			}
			handle_packet_post(rcv_para.sd, packet);
        } else {
        	DBG_OUT("It's a response packet from client, ignored.");
        }

		memset(packet, 0x0, buff_len);
	} /* while(read_packet) */

	DBG_OUT("terminated thread 0x%lx", (unsigned long)pthread_self());

    for (len = 0; len < ARRAY_SIZE(dev_map); len++)
    {
        if (dev_map[len].sd == rcv_para.sd)
        {
            dev_map[len].valid = 0;
            break;
        }
    }
    
	free(packet);
	free(resp);
	pthread_exit((void *)0);
	return NULL;
}