Exemple #1
0
void
view_vcard (int entry_number, vc_component * v)
{
  vc_component *vc = NULL;
  char *val = NULL;

  g_v = v;

  vc = vc_get_next_by_name (g_v, VC_FORMATTED_NAME);
  val = vc_get_value (vc);
  print_footer (entry_number, val ? val : "");

  switch (g_mode)
    {
    case VIEW_IDENT:
      view_ident ();
      break;
    case VIEW_GEO:
      view_geo ();
      break;
    case VIEW_TEL:
      view_tel ();
      break;
    case VIEW_ORG:
      view_org ();
      break;
    case VIEW_MISC:
      view_misc ();
      break;
    default:
      break;
    }

}
Exemple #2
0
static void
view_tel ()
{
  vc_component *vc = NULL;
  char *val = NULL;
  int x = 0;
  int y = 0;
  int i = 0;

  g_mode = VIEW_TEL;

  werase (sub);

  x = (COLS - strlen (HEADING_TEL_STRING)) / 2;
  y = 1;

  wattron (sub, A_UNDERLINE);
  mvwprintw (sub, y, x, HEADING_TEL_STRING);
  wstandend (sub);
  wmove (sub, 3, 0);

  for (i = 1, vc = g_v; i <= 5; i++)
    {
      vc = vc_get_next_by_name (vc, VC_TELEPHONE);
      val = vc_get_value (vc);
      wprintw (sub, "Telephone #%i  : %s\n", i, val ? val : "");
    }

  wprintw (sub, "\n");

  for (i = 1, vc = g_v; i <= 5; i++)
    {
      vc = vc_get_next_by_name (vc, VC_EMAIL);
      val = vc_get_value (vc);
      wprintw (sub, "Email Address #%i  : %s\n", i, val ? val : "");
    }

  wprintw (sub, "\n");

  vc = vc_get_next_by_name (g_v, VC_MAILER);
  val = vc_get_value (vc);
  wprintw (sub, "Email Mailer      : %s\n", val ? val : "");

  touchwin (win);
  wrefresh (sub);
  wrefresh (win);
}
Exemple #3
0
void
get_results (FILE * fp,
             const char *query_string,
             const char *misc_field,
             const int all_emails,
             int *searched, query_result * results, int *rc)
{
  vc_component *v = NULL;
  char *s_result = NULL;
  char *email = NULL;
  char *name = NULL;
  char *misc = NULL;
  vc_component *fn = NULL;
  query_result * r = NULL;

  r = results;
  *rc = 0;
  *searched = 0;
  for (v = parse_vcard_file (fp); NULL != v; v = parse_vcard_file (fp))
    {
      (*searched)++;
      fn = vc_get_next_by_name (v, VC_FORMATTED_NAME);
      name = vc_get_value (fn);
      misc = get_misc_value (v, misc_field);
      if (all_emails)
        {
          for (fn = vc_get_next_by_name (v, VC_EMAIL);
               NULL != fn;
               fn = vc_get_next_by_name(fn, VC_EMAIL))
            {
              email = vc_get_value (fn);
              r = add_result(query_string, name, misc, email, r, rc);
            }
        }
      else
        {
          email = vc_get_preferred_email (v);
          r = add_result(query_string, name, misc, email, r, rc);
        }

      free (misc);
      vc_delete_deep (v);
      v = NULL;
    }
}
Exemple #4
0
static char *
get_misc_value (vc_component * vcard, const char *type_name)
{
  char *ret_val = NULL;
  vc_component *tmp_vc = NULL;

  if (NULL == type_name)
    {
      /* retrieve the default value of the address locality */
      tmp_vc = vc_get_next_by_name (vcard, VC_ADDRESS);
      ret_val = get_val_struct_part (vc_get_value (tmp_vc), ADR_LOCALITY);
    }
  else
    {
      tmp_vc = vc_get_next_by_name (vcard, type_name);
      ret_val = vc_get_value (tmp_vc);
    }

  ret_val = ret_val ? strdup (ret_val) : strdup (" ");

  return ret_val;
}
Exemple #5
0
static void
view_misc ()
{
  vc_component *vc = NULL;
  char *str = NULL;
  char *val = NULL;
  int x = 0;
  int y = 0;

  g_mode = VIEW_MISC;

  werase (sub);

  x = (COLS - strlen (HEADING_MISC_STRING)) / 2;
  y = 1;

  wattron (sub, A_UNDERLINE);
  mvwprintw (sub, y, x, HEADING_MISC_STRING);
  wstandend (sub);
  wmove (sub, 3, 0);

  vc = vc_get_next_by_name (g_v, VC_SORT_STRING);
  val = vc_get_value (vc);
  wprintw (sub, "Sort String  : %s\n", val ? val : "");

  vc = vc_get_next_by_name (g_v, VC_CLASS);
  val = vc_get_value (vc);
  wprintw (sub, "Class       : %s\n", val ? val : "");

  vc = vc_get_next_by_name (g_v, VC_KEY);
  val = vc_get_value (vc);
  wprintw (sub, "Public Key  : %s\n", val ? val : "");

  touchwin (win);
  wrefresh (sub);
  wrefresh (win);
}
Exemple #6
0
static void
view_org ()
{
  vc_component *vc = NULL;
  char *str = NULL;
  char *val = NULL;
  int x = 0;
  int y = 0;

  g_mode = VIEW_ORG;

  werase (sub);

  x = (COLS - strlen (HEADING_ORG_STRING)) / 2;
  y = 1;

  wattron (sub, A_UNDERLINE);
  mvwprintw (sub, y, x, HEADING_ORG_STRING);
  wstandend (sub);
  wmove (sub, 3, 0);

  vc = vc_get_next_by_name (g_v, VC_TITLE);
  val = vc_get_value (vc);
  wprintw (sub, "Title  : %s\n", val ? val : "");

  vc = vc_get_next_by_name (g_v, VC_ROLE);
  val = vc_get_value (vc);
  wprintw (sub, "Role   : %s\n", val ? val : "");

  wprintw (sub, "\n");

  vc = vc_get_next_by_name (g_v, VC_ORGANIZATION);
  val = vc_get_value (vc);

  str = get_val_struct_part (val, ORG_NAME);
  wprintw (sub, "Organization Name       : %s\n", str ? str : "");
  free (str);

  str = get_val_struct_part (val, ORG_UNIT_1);
  wprintw (sub, "Organizational Unit #1  : %s\n", str ? str : "");
  free (str);

  str = get_val_struct_part (val, ORG_UNIT_2);
  wprintw (sub, "Organizational Unit #2  : %s\n", str ? str : "");
  free (str);

  str = get_val_struct_part (val, ORG_UNIT_3);
  wprintw (sub, "Organizational Unit #3  : %s\n", str ? str : "");
  free (str);

  str = get_val_struct_part (val, ORG_UNIT_4);
  wprintw (sub, "Organizational Unit #4  : %s\n", str ? str : "");
  free (str);

  wprintw (sub, "\n");

  vc = vc_get_next_by_name (g_v, VC_LOGO);
  val = vc_get_value (vc);
  wprintw (sub, "Logo  : %s\n", val ? val : "");

  vc = vc_get_next_by_name (g_v, VC_AGENT);
  val = vc_get_value (vc);
  wprintw (sub, "Agent  : %s\n", val ? val : "");

  touchwin (win);
  wrefresh (sub);
  wrefresh (win);
}
Exemple #7
0
static void
view_geo ()
{
  vc_component *vc = NULL;
  char *str = NULL;
  char *val = NULL;
  int x = 0;
  int y = 0;

  g_mode = VIEW_GEO;

  werase (sub);

  x = (COLS - strlen (HEADING_GEO_STRING)) / 2;
  y = 1;

  wattron (sub, A_UNDERLINE);
  mvwprintw (sub, y, x, HEADING_GEO_STRING);
  wstandend (sub);
  wmove (sub, 3, 0);

  vc = vc_get_next_by_name (g_v, VC_GEOGRAPHIC_POSITION);
  val = vc_get_value (vc);

  str = get_val_struct_part (val, GEO_LATITUDE);
  wprintw (sub, "Latitude   : %s\n", str ? str : "");
  free (str);

  str = get_val_struct_part (val, GEO_LONGITUDE);
  wprintw (sub, "Longitude  : %s\n", str ? str : "");
  free (str);

  wprintw (sub, "\n");
  vc = vc_get_next_by_name (g_v, VC_TIME_ZONE);
  val = vc_get_value (vc);
  wprintw (sub, "Time Zone  : %s\n", val ? val : "");

  wprintw (sub, "\n");

  vc = vc_get_next_by_name (g_v, VC_ADDRESS);
  val = vc_get_value (vc);

  str = get_val_struct_part (val, ADR_PO_BOX);
  wprintw (sub, "Post Office Box   : %s\n", str ? str : "");
  free (str);

  str = get_val_struct_part (val, ADR_EXT_ADDRESS);
  wprintw (sub, "Extended Address  : %s\n", str ? str : "");
  free (str);

  str = get_val_struct_part (val, ADR_STREET);
  wprintw (sub, "Street Address    : %s\n", str ? str : "");
  free (str);

  str = get_val_struct_part (val, ADR_LOCALITY);
  wprintw (sub, "Locality          : %s\n", str ? str : "");
  free (str);

  str = get_val_struct_part (val, ADR_REGION);
  wprintw (sub, "Region            : %s\n", str ? str : "");
  free (str);

  str = get_val_struct_part (val, ADR_POSTAL_CODE);
  wprintw (sub, "Postal Code       : %s\n", str ? str : "");
  free (str);

  str = get_val_struct_part (val, ADR_COUNTRY);
  wprintw (sub, "Country           : %s\n", str ? str : "");
  free (str);

  wprintw (sub, "\n");
  touchwin (win);
  wrefresh (sub);
  wrefresh (win);
}
Exemple #8
0
static void
view_ident ()
{
  vc_component *vc = NULL;
  char *val = NULL;
  int x = 0;
  int y = 0;
  int i = 0;

  g_mode = VIEW_IDENT;

  werase (sub);

  x = (COLS - strlen (HEADING_IDENT_STRING)) / 2;
  y = 1;

  wattron (sub, A_UNDERLINE);
  mvwprintw (sub, y, x, HEADING_IDENT_STRING);
  wstandend (sub);
  wmove (sub, 3, 0);

  vc = vc_get_next_by_name (g_v, VC_FORMATTED_NAME);
  val = vc_get_value (vc);
  wprintw (sub, "Name         : %s\n", val ? val : "");

  vc = vc_get_next_by_name (g_v, VC_NICKNAME);
  val = vc_get_value (vc);
  wprintw (sub, "Nickname     : %s\n", val ? val : "");

  vc = vc_get_next_by_name (g_v, VC_BIRTHDAY);
  val = vc_get_value (vc);
  wprintw (sub, "Birthday     : %s\n", val ? val : "");

  wprintw (sub, "\n");

  vc = vc_get_next_by_name (g_v, VC_URL);
  val = vc_get_value (vc);
  wprintw (sub, "URL    : %s\n", val ? val : "");

  vc = vc_get_next_by_name (g_v, VC_PHOTO);
  val = vc_get_value (vc);
  wprintw (sub, "Photo  : %s\n", val ? val : "");

  vc = vc_get_next_by_name (g_v, VC_SOUND);
  val = vc_get_value (vc);
  wprintw (sub, "Sound  : %s\n", val ? val : "");

  wprintw (sub, "\n");

  vc = vc_get_next_by_name (g_v, VC_CATEGORIES);
  val = vc_get_value (vc);
  wprintw (sub, "Categories  : %s\n", val ? val : "");

  vc = vc_get_next_by_name (g_v, VC_REVISION);
  val = vc_get_value (vc);
  wprintw (sub, "Revision    : %s\n", val ? val : "");

  for (i = 1, vc = g_v; i <= 5; i++)
    {
      vc = vc_get_next_by_name (vc, VC_NOTE);
      val = vc_get_value (vc);
      wprintw (sub, "Note        : %s\n", val ? val : "");
    }

  touchwin (win);
  wrefresh (sub);
  wrefresh (win);
}