Пример #1
0
/*!
  \brief Set login parameters for driver/database
  
  \param driver driver name
  \param database database name
  \param user user name
  \param password password string
  \param host host name
  \param port
  \param overwrite TRUE to overwrite exising connections
  
  \return DB_OK on success
  \return DB_FAILED on failure
 */
int db_set_login2(const char *driver, const char *database, const char *user,
		 const char *password, const char *host, const char *port,
                 int overwrite)
{
    return set_login(driver, database, user,
                     password, host, port, overwrite);
}
Пример #2
0
void
login_dialog::init_settings()
{
  QSettings settings("Manitou-Mail", "manitou-ui");
  set_login(settings.value("login").toString());
  set_dbname(settings.value("dbname").toString());
  set_host(settings.value("host").toString());
  set_params(settings.value("params").toString());
}
Пример #3
0
/*!
  \brief Set login parameters for driver/database
  
  \deprecated Use db_set_login2() instead.
  
  \todo: GRASS 8: to be replaced by db_set_login2().

  \param driver driver name
  \param database database name
  \param user user name
  \param password password string
  
  \return DB_OK on success
  \return DB_FAILED on failure
 */
int db_set_login(const char *driver, const char *database, const char *user,
                 const char *password)
{
    return set_login(driver, database, user,
                     password, NULL, NULL, FALSE);
}
Пример #4
0
int net_init(int argc, char **argv)
{
    int i,x,db_level=0;
    base=&local_base;

    local_client_number=0;

    if (!main_net_cfg)
        main_net_cfg=new net_configuration;

    for (i=1; i<argc; i++)
    {
        if (!strcmp(argv[i],"-nonet"))
        {
            printf( "Net: Disabled (-nonet)\n" );
            return 0;
        }
        else if (!strcmp(argv[i],"-port"))
        {
            if( i == argc - 1 ||
                !sscanf( argv[i + 1], "%d", &x ) ||
                x < 1 || x > 0x7fff )
            {
                fprintf( stderr, "Net: Bad value following -port, use 1..32000\n" );
                return 0;
            }
            else
            {
                main_net_cfg->port = x;
            }
        }
        else if( !strcmp( argv[i], "-net" ) && i < argc-1 )
        {
            i++;
            strncpy(main_net_cfg->server_name, argv[i],
                    sizeof(main_net_cfg->server_name) - 1);
            main_net_cfg->server_name[sizeof(main_net_cfg->server_name) - 1]
                = '\0';
            main_net_cfg->state = net_configuration::CLIENT;
        }
        else if (!strcmp(argv[i],"-ndb"))
        {
            if (i==argc-1 || !sscanf(argv[i+1],"%d",&x) || x<1 || x>3)
            {
                fprintf(stderr,"Net: Bad value following -ndb, use 1..3\n" );
                return 0;
            }
            else
            {
                db_level = x;
            }
        }
        else if( !strcmp( argv[i], "-server" ) )
        {
            main_net_cfg->state = net_configuration::SERVER;
        }
        else if( !strcmp( argv[i], "-min_players" ) )
        {
            i++;
            int x = atoi( argv[i] );
            if (x >= 1 && x <= 8)
            {
                main_net_cfg->min_players=x;
            }
            else
            {
                fprintf(stderr,"bad value for min_players use 1..8\n");
            }
        }
    }

    net_protocol *n = net_protocol::first, *usable = NULL;     // find a usable protocol from installed list
    int total_usable = 0;
    for( ; n; n = n->next )                                    // show a list of usables, just to be cute
    {
        fprintf( stderr, "Protocol %s : ",n->installed() ? "Installed" : "Not_installed" );
        fprintf( stderr, "%s\n", n->name() );
        if( n->installed() )
        {
            total_usable++;
            usable=n;
        }
    }

    if (!usable)
    {
        fprintf(stderr,"Net: No network protocols installed\n");
        return 0;
    }
    prot=usable;
    prot->set_debug_printing((net_protocol::debug_type)db_level);

    if (main_net_cfg->state==net_configuration::SERVER)
        set_login(main_net_cfg->name);

    comm_sock=game_sock=NULL;
    if (main_net_cfg->state==net_configuration::CLIENT)
    {
        dprintf("Attempting to locate server %s, please wait\n",main_net_cfg->server_name);
        char const *sn=main_net_cfg->server_name;
        net_server=prot->get_node_address(sn,DEFAULT_COMM_PORT,0);
        if (!net_server)
        {
            dprintf(symbol_str("unable_locate"));
            exit(0);
        }
        dprintf("Server located!  Please wait while data loads....\n");
    }

#if HAVE_NETWORK
    fman = new file_manager(argc,argv,prot); // manages remote file access
#endif
    game_face = new game_handler;
    join_array=(join_struct *)malloc(sizeof(join_struct)*MAX_JOINERS);
    base->join_list=NULL;
    base->mem_lock=0;
    base->calc_crcs=0;
    base->get_lsf=0;
    base->wait_reload=0;
    base->need_reload=0;
    base->input_state=INPUT_COLLECTING;
    base->current_tick=0;
    base->packet.packet_reset();

    return 1;
}
Пример #5
0
/**
 * Uploading a VikTrwLayer
 *
 * @param vtl VikTrwLayer
 * @param track_name if not null, the name of the track to upload
 */
static void osm_traces_upload_viktrwlayer ( VikTrwLayer *vtl, const gchar *track_name )
{
  GtkWidget *dia = gtk_dialog_new_with_buttons (_("OSM upload"),
                                                 VIK_GTK_WINDOW_FROM_LAYER(vtl),
                                                 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
                                                 GTK_STOCK_CANCEL,
                                                 GTK_RESPONSE_REJECT,
                                                 GTK_STOCK_OK,
                                                 GTK_RESPONSE_ACCEPT,
                                                 NULL);

  const gchar *default_user = get_default_user();
  const gchar *pref_user = a_preferences_get(VIKING_OSM_TRACES_PARAMS_NAMESPACE "username")->s;
  const gchar *pref_password = a_preferences_get(VIKING_OSM_TRACES_PARAMS_NAMESPACE "password")->s;
  const gchar *name = NULL;
  GtkWidget *user_label, *user_entry;
  GtkWidget *password_label, *password_entry;
  GtkWidget *name_label, *name_entry;
  GtkWidget *description_label, *description_entry;
  GtkWidget *tags_label, *tags_entry;
  GtkComboBox *visibility;
  const OsmTraceVis_t *vis_t;

  user_label = gtk_label_new(_("Email:"));
  user_entry = gtk_entry_new();
  if (user != NULL && user[0] != '\0')
    gtk_entry_set_text(GTK_ENTRY(user_entry), user);
  else if (pref_user != NULL && pref_user[0] != '\0')
    gtk_entry_set_text(GTK_ENTRY(user_entry), pref_user);
  else if (default_user != NULL)
    gtk_entry_set_text(GTK_ENTRY(user_entry), default_user);
  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dia)->vbox), user_label, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dia)->vbox), user_entry, FALSE, FALSE, 0);
  gtk_widget_set_tooltip_markup(GTK_WIDGET(user_entry),
                        _("The email used as login\n"
                        "<small>Enter the email you use to login into www.openstreetmap.org.</small>"));

  password_label = gtk_label_new(_("Password:"******"The password used to login\n"
                        "<small>Enter the password you use to login into www.openstreetmap.org.</small>"));

  name_label = gtk_label_new(_("File's name:"));
  name_entry = gtk_entry_new();
  if (track_name != NULL)
    name = track_name;
  else
    name = vik_layer_get_name(VIK_LAYER(vtl));
  gtk_entry_set_text(GTK_ENTRY(name_entry), name);
  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dia)->vbox), name_label, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dia)->vbox), name_entry, FALSE, FALSE, 0);
  gtk_widget_set_tooltip_markup(GTK_WIDGET(name_entry),
                        _("The name of the file on OSM\n"
                        "<small>This is the name of the file created on the server."
			"This is not the name of the local file.</small>"));

  description_label = gtk_label_new(_("Description:"));
  description_entry = gtk_entry_new();
  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dia)->vbox), description_label, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dia)->vbox), description_entry, FALSE, FALSE, 0);
  gtk_widget_set_tooltip_text(GTK_WIDGET(description_entry),
                        _("The description of the trace"));

  tags_label = gtk_label_new(_("Tags:"));
  tags_entry = gtk_entry_new();
  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dia)->vbox), tags_label, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dia)->vbox), tags_entry, FALSE, FALSE, 0);
  gtk_widget_set_tooltip_text(GTK_WIDGET(tags_entry),
                        _("The tags associated to the trace"));

  visibility = GTK_COMBO_BOX(gtk_combo_box_new_text ());
  for (vis_t = OsmTraceVis; vis_t->combostr != NULL; vis_t++)
	gtk_combo_box_append_text(visibility, vis_t->combostr);
  /* Set identifiable by default */
  gtk_combo_box_set_active(visibility, 0);
  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dia)->vbox), GTK_WIDGET(visibility), FALSE, FALSE, 0);

  /* User should think about it first... */
  gtk_dialog_set_default_response ( GTK_DIALOG(dia), GTK_RESPONSE_REJECT );

  gtk_widget_show_all ( dia );
  gtk_widget_grab_focus ( description_entry );

  if ( gtk_dialog_run ( GTK_DIALOG(dia) ) == GTK_RESPONSE_ACCEPT )
  {
    gchar *title = NULL;

    /* overwrite authentication info */
    set_login(gtk_entry_get_text(GTK_ENTRY(user_entry)),
              gtk_entry_get_text(GTK_ENTRY(password_entry)));

    /* Storing data for the future thread */
    OsmTracesInfo *info = g_malloc(sizeof(OsmTracesInfo));
    info->name        = g_strdup(gtk_entry_get_text(GTK_ENTRY(name_entry)));
    info->description = g_strdup(gtk_entry_get_text(GTK_ENTRY(description_entry)));
    /* TODO Normalize tags: they will be used as URL part */
    info->tags        = g_strdup(gtk_entry_get_text(GTK_ENTRY(tags_entry)));
    info->vistype     = &OsmTraceVis[gtk_combo_box_get_active(visibility)];
    info->vtl         = VIK_TRW_LAYER(g_object_ref(vtl));
    info->track_name  = (track_name == NULL) ? NULL : g_strdup(track_name);

    title = g_strdup_printf(_("Uploading %s to OSM"), info->name);

    /* launch the thread */
    a_background_thread(VIK_GTK_WINDOW_FROM_LAYER(vtl),          /* parent window */
			title,                                   /* description string */
			(vik_thr_func) osm_traces_upload_thread, /* function to call within thread */
			info,                                    /* pass along data */
			(vik_thr_free_func) oti_free,            /* function to free pass along data */
			(vik_thr_free_func) NULL,
			1 );
    g_free ( title ); title = NULL;
  }
  gtk_widget_destroy ( dia );
}