SessionDispatcher::SessionDispatcher(QObject *parent)
//    QObject(parent)
{
    sessioniface = new QDBusInterface("com.ubuntukylin.session",
                               "/",
                               "com.ubuntukylin.session",
                               QDBusConnection::sessionBus());

//    QObject::connect(sessioniface, SIGNAL(autostartmanage_data_signal(QVariantMap)), this, SLOT(handlerAutoManageData(QVariantMap)));
    QObject::connect(sessioniface, SIGNAL(autostartmanage_data_signal(QStringList)), this, SLOT(handlerAutoManageData(QStringList)));
    QObject::connect(sessioniface, SIGNAL(autostartmanage_status_signal(QString)), this, SLOT(handlerAutoManageStatus(QString)));
    QObject::connect(sessioniface, SIGNAL(autostartmanage_error_signal(QString)), this, SLOT(handlerAutoManageError(QString)));

    QObject::connect(sessioniface, SIGNAL(subpage_data_signal(QStringList)), this, SLOT(handlerScanCleanerData(QStringList)));
    QObject::connect(sessioniface, SIGNAL(subpage_status_signal(QString)), this, SLOT(handlerScanCleanerStatus(QString)));
    QObject::connect(sessioniface, SIGNAL(subpage_error_signal(QString)), this, SLOT(handlerScanCleanerError(QString)));

    thread = new KThread(this);
    QObject::connect(sessioniface, SIGNAL(display_scan_process(QString)), this, SLOT(handler_scan_process(QString)));
    QObject::connect(sessioniface, SIGNAL(scan_complete(QString)), this, SLOT(handler_scan_complete(QString)));
    QObject::connect(sessioniface, SIGNAL(total_data_transmit(QString, QString)), this, SLOT(handler_total_data_transmit(QString,QString)));
    QObject::connect(sessioniface, SIGNAL(youkerid_whoami_signal(QString, QString)), this, SLOT(handlerYoukerID(QString, QString)));
    QObject::connect(sessioniface, SIGNAL(youkerid_logout_signal()), this, SLOT(handlerLogoutSuccess()));
    QObject::connect(sessioniface, SIGNAL(youkerid_login_fail_signal()), this, SLOT(handlerLoginFail()));


    QObject::connect(sessioniface, SIGNAL(notify_boolean(QString, bool)), this, SLOT(handler_notify_boolean(QString, bool)));
    QObject::connect(sessioniface, SIGNAL(notify_int(QString, int)), this, SLOT(handler_notify_int(QString, int)));
    QObject::connect(sessioniface, SIGNAL(notify_double(QString, double)), this, SLOT(handler_notify_double(QString, double)));
    QObject::connect(sessioniface, SIGNAL(notify_string(QString, QString)), this, SLOT(handler_notify_string(QString, QString)));
}
예제 #2
0
파일: gui_help.c 프로젝트: Bhattiasif/gdis
void help_init(void)
{
gint n;
gchar *filename, *line, *topic;
gpointer scan;
GString *buffer;

/* hash table with topic label as the key */
sysenv.manual = g_hash_table_new(g_str_hash, g_str_equal);

/* open the manual file for scanning */
filename = g_build_filename(sysenv.gdis_path, MANUAL_FILE, NULL);
printf("scanning: %s\n", filename);
scan = scan_new(filename);
g_free(filename);
if (!scan)
  {
  help_topic_new(NULL, NULL);
  return;
  }

/* process the manual file */
topic=NULL;
buffer = g_string_new(NULL);
line = scan_get_line(scan);
while (!scan_complete(scan))
  {
  if (g_ascii_strncasecmp(line, "%topic ", 7) == 0)
    {
/* add any old data */
    if (topic && buffer->len)
      {
      help_topic_new(topic, buffer->str);
      buffer = g_string_set_size(buffer, 0);
      g_free(topic);
      }
/* remove trailing <cr> */
    n = strlen(&line[7]);
    topic = g_strndup(&line[7], n-1);
    }
  else
    {
/* append everything that's not a topic to the current buffer */
    if (topic)
      g_string_append(buffer, line);
    }

  line = scan_get_line(scan);
  }

/* done - add the last topic found */
if (topic)
  help_topic_new(topic, buffer->str);

g_string_free(buffer, TRUE);
g_free(topic);

scan_free(scan);
}
예제 #3
0
void read_nwchem_basis_library(gpointer scan, gpointer config)
{
gint i, num_tokens;
gchar *line, **buff1, **buff2;
struct nwchem_pak *nwchem;

nwchem = config_data(config);
if (!nwchem)
  return;

while (!scan_complete(scan))
  {
  line = scan_get_line(scan);

  if (g_strrstr(line, "end"))
    break;

#if DEBUG_READ_NWCHEM_BASIS_LIBRARY
printf("+%s", line);
#endif

/* cope with ";" element separator */
  buff1 = g_strsplit(line, ";", -1);
  i=0;

  if (buff1)
    {
    while (buff1[i])
      {
      buff2 = tokenize(buff1[i], &num_tokens);

      if (num_tokens > 2)
        {
#if DEBUG_READ_NWCHEM_BASIS_LIBRARY
printf("[%s] -> [%s]\n", buff2[0], buff2[2]);
#endif
        g_hash_table_insert(nwchem->library, g_strdup(buff2[0]), g_strdup(buff2[2]));
        }
      g_strfreev(buff2);
      i++;
      }
    }
  g_strfreev(buff1);
  }
}
예제 #4
0
gint read_aims(gchar *filename, struct model_pak *model)
{
gint i, num_tokens;
gchar **buff;
gpointer scan;
struct core_pak *core;

g_assert(model != NULL);

scan = scan_new(filename);
if (!scan) return(1);

while (!scan_complete(scan)) {

  buff = scan_get_tokens(scan, &num_tokens);

/* 
   for debugging purposes 
   produces a compiler warning about an
	implicit declaration of function 'g_printf'
   though this is a valid glib function since 2.2
	http://library.gnome.org/devel/glib/2.18/glib-String-Utility-Functions.html#g-printf
*/
/*
  for (i=0; i<num_tokens; i++) {
	g_printf(" %s ", buff[i]);
  }
  printf("\n");
*/

  if (!buff) break;

  /* read cell vectors */
  if ( g_strrstr(*buff, "lattice_vector") != NULL ) {
     for (i=0 ; i<3 ; i++) {
         if (num_tokens >= 3) {
            model->latmat[i] = str_to_float(*(buff+1));
            model->latmat[i+3] = str_to_float(*(buff+2));
            model->latmat[i+6] = str_to_float(*(buff+3));
         }
         else { 
            gui_text_show(ERROR, "error reading AIMS lattice vectors \n"); 
            return(2);
         }
         g_strfreev(buff);
         buff = scan_get_tokens(scan, &num_tokens);
     }
     model->periodic = 3;
     model->construct_pbc = TRUE;
  }

  /* read coordinates */
  if ( g_strrstr(*buff, "atom") != NULL ) {
     if ( ( num_tokens >= 4 ) && ( elem_symbol_test(*(buff+4)) ) ) {
        core = new_core(*(buff+4), model);
        core->x[0] = str_to_float(*(buff+1));
        core->x[1] = str_to_float(*(buff+2));
        core->x[2] = str_to_float(*(buff+3));
        model->cores = g_slist_prepend(model->cores, core);
     }
     else {
        gui_text_show(ERROR, "error reading AIMS lattice vectors \n"); 
        return(2);
     }
  }

  g_strfreev(buff);
}

/* done reading */
scan_free(scan);

/* model setup */
g_free(model->filename);
model->filename = g_strdup(filename);

g_free(model->basename);
model->basename = g_path_get_basename(filename);

model->fractional = FALSE;
model_prep(model);

return(0);
}
예제 #5
0
// no coords - just control data for the run
// coords - .pdb file
// topology - .frx file
gint reaxmd_input_import(gpointer import)
{
gint *symbols, num_symbols, unknown;
gchar *line, *fullname_model;
gchar *filename, *filepath;
gpointer scan, config;
GString *unparsed;
struct reaxmd_pak *reaxmd;
struct model_pak *model;
FILE *fp;

scan = scan_new(import_fullpath(import));
if (!scan)
  return(1);

/* populate symbol table */
reaxmd_symbols_init(scan);

config = config_new(REAXMD, NULL);
reaxmd = config_data(config);

unparsed = g_string_new(NULL);

while (!scan_complete(scan))
  {
  symbols = scan_get_symbols(scan, &num_symbols);
  if (num_symbols)
    {
    unknown = FALSE;
/* process first recognized symbol */
    switch (symbols[0])
      {
      case REAXMD_NSTEPS:
        reaxmd->total_steps = parse_nth_token_dup(1, scan_cur_line(scan));
        break;

      case REAXMD_TIMESTEP:
      case REAXMD_TEMPERATURE:
      case REAXMD_THERMOSTAT:
      case REAXMD_BAROSTAT:
      case REAXMD_CUTOFF:
      case REAXMD_UPDATE:
      case REAXMD_NWRITE:
      case REAXMD_GRID:
        break;

      case REAXMD_PLUMED_FILE:
        filename = parse_nth_token_dup(1, scan_cur_line(scan));
        filepath = g_build_filename(import_path(import), filename, NULL);
//printf("Looking for: %s\n", filepath);
        if (g_file_test(filepath, G_FILE_TEST_EXISTS))
          project_job_file_append(NULL, filepath, sysenv.workspace);
        else
          gui_text_show(ERROR, "REAXMD plumed file was not found!\n"); 
        g_free(filename);
        g_free(filepath);
        break;

      default:
        unknown = TRUE;
      }
    g_free(symbols);
    }
  else
    unknown=TRUE;

  if (unknown)
    {
    line = scan_cur_line(scan);
    if (line)
      g_string_append(unparsed, line);
    }
  }

config_unparsed_set(g_string_free(unparsed, FALSE), config);
/* CURRENT - free this, until we add a GUI */
//import_object_add(IMPORT_CONFIG, config, import);
config_free(config);

/* done irx parse */
scan_free(scan);

/* NEW - attempt to load reference coordinates */
fullname_model = parse_extension_set(import_fullpath(import), "pdb");
fp = fopen(fullname_model, "rt");
if (fp)
  {
  model = model_new();
  read_pdb_block(fp, model);
  fclose(fp);
  import_object_add(IMPORT_MODEL, model, import);
  }
else
  {
  gui_text_show(WARNING, "Failed to open reference PDB model for ReaxMD.\n");
  }
g_free(fullname_model);

/* init */
import_init(import);

return(0);
}
예제 #6
0
gint nwchem_input_import(gpointer import)
{
gint *symbols, num_symbols, num_tokens, value;
gchar *line, **buff;
gpointer scan, config;
GString *unparsed;
struct model_pak *model=NULL; // CURRENT - will break if more than one in a file
struct nwchem_pak *nwchem;

scan = scan_new(import_fullpath(import));
if (!scan)
  return(1);

/* populate symbol table */
nwchem_scan_symbols_init(scan);

config = config_new(NWCHEM, NULL);
nwchem = config_data(config);

unparsed = g_string_new(NULL);

while (!scan_complete(scan))
  {
  symbols = scan_get_symbols(scan, &num_symbols);

  if (num_symbols)
    {
/* process first recognized symbol */
    value = symbols[0];
    switch (value)
      {
      case NWCHEM_START:
/* TODO - could this serve as title? */
        nwchem->start = parse_strip(scan_cur_line(scan));
        break;

      case NWCHEM_BASIS:
// TODO - don't want to use this for predefined basis sets
        read_nwchem_basis_library(scan, config);
        break;

      case NWCHEM_CHARGE:
        line = scan_cur_line(scan);
        buff = tokenize(line, &num_tokens);
        if (num_tokens > 1)
          nwchem->charge = g_strdup(buff[1]);
        g_strfreev(buff);
        break;

      case NWCHEM_GEOMETRY:
        if (!model)
          {
          model = model_new();
          import_object_add(IMPORT_MODEL, model, import);
          }
        read_nwchem_geometry(scan, model);
        break;

      case NWCHEM_SYSTEM:
        if (!model)
          {
          model = model_new();
          import_object_add(IMPORT_MODEL, model, import);
          }
        read_nwchem_system(scan, model);
        break;

      case NWCHEM_TASK:
        read_nwchem_task(scan, config, symbols, num_symbols);
        break;

      default:
/* add lines that have recognized symbols (but no special trigger) to unparsed */
/* this'll happen for symbols that occur in multiple locations (eg dft) */
        line = scan_cur_line(scan);
        if (line)
          g_string_append(unparsed, line);
      }

    g_free(symbols);
    }
  else
    {
/* add non-NULL lines to unparsed list */
    line = scan_cur_line(scan);
    if (line)
      g_string_append(unparsed, line);
    }
  }

config_unparsed_set(g_string_free(unparsed, FALSE), config);
import_object_add(IMPORT_CONFIG, config, import);

scan_free(scan);

import_init(import);

return(0);
}
예제 #7
0
gint read_nwchem_geometry(gpointer scan, struct model_pak *model)
{
gint n, zmode=0, end_count=0;
gchar **buff;
struct core_pak *core;

#if DEBUG_READ_NWCHEM_GEOMETRY
printf("read_nwchem_geometry(): start\n");
#endif

// TODO - rewrite this using symbol scanning functionality
while (!scan_complete(scan))
  {
  buff = scan_get_tokens(scan, &n);

// zmatrix?
   if (g_ascii_strncasecmp(*buff, "zmatrix", 7) == 0)
     {
     zmode = 1;
     g_strfreev(buff);
     continue;
     }
   if (g_ascii_strncasecmp(*buff, "variables", 9) == 0)
     {
     zmode = 2;
     g_strfreev(buff);
     continue;
     }
   if (g_ascii_strncasecmp(*buff, "constants", 9) == 0)
     {
     zmode = 3;
     g_strfreev(buff);
     continue;
     }

// end?
   if (n)
     {
     if (g_ascii_strncasecmp(*buff, "end", 3) == 0)
       {
       g_strfreev(buff);
/* if we processed zmatrix entries - expect 2 x end */
       if (zmode && !end_count)
         {
/* keep going until we hit a second end ... */
         end_count++;
         continue;
         }
/* exit */
       break;
       }
     }

/* main parse */
  switch (zmode)
    {
// cartesian coords
    case 0:
// can cart coord line have >4 tokens?
      if (n == 4)
        {
        if (elem_test(*buff))
          {
          core = core_new(*buff, NULL, model);
          model->cores = g_slist_prepend(model->cores, core);
          core->x[0] = str_to_float(*(buff+1));
          core->x[1] = str_to_float(*(buff+2));
          core->x[2] = str_to_float(*(buff+3));

#if DEBUG_READ_NWCHEM_GEOMETRY
printf("Added [%s] ", *buff);
P3VEC(": ", core->x);
#endif
          }
        }
      break;

// zmatrix coords
    case 1:
#if DEBUG_READ_NWCHEM_GEOMETRY
printf("zcoord: %s", scan_cur_line(scan));
#endif
      zmat_nwchem_core_add(scan_cur_line(scan), model->zmatrix);
      break;

// zmatrix vars
    case 2:
#if DEBUG_READ_NWCHEM_GEOMETRY
printf("zvar: %s", scan_cur_line(scan));
#endif
      zmat_var_add(scan_cur_line(scan), model->zmatrix);
      break;

// zmatrix consts
    case 3:
#if DEBUG_READ_NWCHEM_GEOMETRY
printf("zconst: %s", scan_cur_line(scan));
#endif
      zmat_const_add(scan_cur_line(scan), model->zmatrix);
      break;
    }

  g_strfreev(buff);
  }

if (zmode)
  {
#if DEBUG_READ_NWCHEM_GEOMETRY
printf("Creating zmatrix cores...\n");
#endif
  zmat_angle_units_set(model->zmatrix, DEGREES);
  zmat_process(model->zmatrix, model);
  }

#if DEBUG_READ_NWCHEM_GEOMETRY
printf("read_nwchem_geometry(): stop\n");
#endif

return(0);
}
예제 #8
0
gint read_nwchem_system(gpointer scan, struct model_pak *model)
{
gint *symbols, num_symbols, num_tokens;
gchar **buff;

// rewind
scan_put_line(scan);

while (!scan_complete(scan))
  {
  symbols = scan_get_symbols(scan, &num_symbols);

  if (num_symbols)
    {
/* process first recognized symbol */
    switch (symbols[0])
      {
      case NWCHEM_SYSTEM:
        if (num_symbols > 1)
          {
          switch (symbols[1])
            {
            case NWCHEM_CRYSTAL:
              model->periodic = 3;
              model->fractional = TRUE;
/* lengths */
              buff = scan_get_tokens(scan, &num_tokens);
              if (num_tokens > 5)
                {
                model->pbc[0] = str_to_float(buff[1]);
                model->pbc[1] = str_to_float(buff[3]);
                model->pbc[2] = str_to_float(buff[5]);
                }
              g_strfreev(buff);
/* angles */
              buff = scan_get_tokens(scan, &num_tokens);
              if (num_tokens > 5)
                {
                model->pbc[3] = D2R*str_to_float(buff[1]);
                model->pbc[4] = D2R*str_to_float(buff[3]);
                model->pbc[5] = D2R*str_to_float(buff[5]);
                }
              g_strfreev(buff);
              break;

            case NWCHEM_SURFACE:
              model->periodic = 2;
              model->fractional = TRUE;
/* lengths */
              buff = scan_get_tokens(scan, &num_tokens);
              if (num_tokens > 3)
                {
                model->pbc[0] = str_to_float(buff[1]);
                model->pbc[1] = str_to_float(buff[3]);
                }
              g_strfreev(buff);
/* angles */
              buff = scan_get_tokens(scan, &num_tokens);
              if (num_tokens > 1)
                model->pbc[5] = D2R*str_to_float(buff[1]);
              g_strfreev(buff);
              break;

            case NWCHEM_POLYMER:
              model->periodic = 1;
              model->fractional = TRUE;
/* length */
              buff = scan_get_tokens(scan, &num_tokens);
              if (num_tokens > 1)
                model->pbc[0] = str_to_float(buff[1]);
              g_strfreev(buff);
              break;

            default:
              model->periodic = 0;
              model->fractional = FALSE;
            }
          }

        break; 

      case NWCHEM_END:
        g_free(symbols);
        return(0);
      }
    g_free(symbols);
    }
  }

return(0);
}
void ScanAppThread::run()
{
	emit scan_complete(adb_tools->get_app_list(*app_list));
}
예제 #10
0
gint read_rietica(gchar *filename, struct model_pak *model)
{
gint i, phases=0, skip, num_tokens;
gchar **buff, *line;
float x, y, z;
gpointer scan;
GSList *list;
struct core_pak *core;

/* checks */
g_assert(model != NULL);
scan = scan_new(filename);
if (!scan)
  return(1);

/* FIXME - stop the previous file routines setting this */
model->id = -1;

while (!scan_complete(scan))
  {
  buff = scan_get_tokens(scan, &num_tokens);
  
/* search for structure start */
  if (num_tokens)
    {
    if (g_ascii_strncasecmp(*buff, "***", 3) == 0)
      {
      if (phases)
        model = model_new();
      phases++;

/* structure name - omit the 1st and last tokens (ie "***") */
      if (num_tokens > 1)
        {
        g_free(*(buff+num_tokens-1));
        *(buff+num_tokens-1) = NULL;
        g_free(model->basename);
        model->basename = g_strjoinv(" ", buff+1);
        }

/* parse spacegroup */
      line = scan_get_line(scan);
      line = scan_get_line(scan);
      model->sginfo.spacename = g_strstrip(g_strdup(line));
      model->sginfo.spacenum = -1;

/* parse a structure */
      skip = 0;
      while (!scan_complete(scan))
        {
        g_strfreev(buff);
        buff = scan_get_tokens(scan, &num_tokens);

        if (num_tokens)
          {
          if (elem_symbol_test(*buff))
            {
/* new core */
/*
            if (num_tokens > 6)
*/
              {
              core = new_core(*buff, model);
              model->cores = g_slist_prepend(model->cores, core);

/* formatted output can result in -ve signs "joining" tokens */
              line = scan_cur_line(scan);
/* no doubt some fortran programmer thought this was a clever format */
              sscanf(line, "%*16c%8f%8f%8f", &x, &y, &z);
              VEC3SET(core->x, x, y, z);

/*
printf("> %s", line);
P3VEC(" - ", core->x);
              core->x[0] = str_to_float(*(buff+2));
              core->x[1] = str_to_float(*(buff+3));
              core->x[2] = str_to_float(*(buff+4));
              core->sof = str_to_float(*(buff+6));
*/

              skip = 0;
              }
            }
          else
            skip++;
          }

/* 4 lines after the last core - parse cell info and terminate structure */
        if (skip == 4)
          {
          if (num_tokens > 5)
            {
            for (i=6 ; i-- ; )
              model->pbc[i] = str_to_float(*(buff+i));
            model->pbc[3] *= D2R;
            model->pbc[4] *= D2R;
            model->pbc[5] *= D2R;
            }
          break;
          }
        }
      }
    }
  g_strfreev(buff);
  }

/* setup all new structures */
for (list=sysenv.mal ; list ; list=g_slist_next(list))
  {
  model = list->data;

  if (model->id == -1)
    {
    model->id = RIETICA;
    model->periodic = 3;
    model->fractional = TRUE;
    strcpy(model->filename, filename);
    model->cores = g_slist_reverse(model->cores);
    model_prep(model);
    }
  }

scan_free(scan);

return(0);
}