Logo Search packages:      
Sourcecode: g2ipmsg version File versions  Download package

int info_message_window ( const gchar *  user,
const gchar *  ipaddr,
unsigned long  command,
const char *  message 
)

クライアント情報ダイアログを表示する

Parameters:
[in] user ユーザ名
[in] ipaddr IPアドレス
[in] command 情報種別
  • IPMSG_SENDINFO クライアント情報を表示
  • IPMSG_SENDABSENCEINFO 不在情報を表示
[in] message 表示する文章
Return values:
0 正常終了
-EINVAL messageがNULLである.
-EINVAL 不正なcommandを引き渡した.

Definition at line 276 of file dialog.c.

References client_info_add_text(), convert_string_internal(), get_asymkey_part, get_sign_part, and get_symkey_part.

Referenced by ipmsg_proc_send_info_packets().

                                              {
      GtkWidget          *window = NULL;  /*  ダイアログウィンドウ  */
      GtkLabel        *userlabel = NULL;  /*  ユーザ名表示ラベル  */
      GtkLabel        *typelabel = NULL;  /*  情報種別表示ラベル  */
      userdb_t        *user_info = NULL;  /*  ユーザ情報          */
      char            buffer[64];         /*  文字列整形用バッファ  */
      GtkTextView     *text_view = NULL;  /*  表示領域用テキストビュー  */
      GtkTextBuffer *text_buffer = NULL;  /*  表示領域のテキストバッファ */
      gchar    *internal_message = NULL;  /*  表示文字列の内部形式格納領域  */
      size_t                 len = 0;     /*  表示文字列長  */
      unsigned long         skey = 0;     /*  対称鍵暗号処理能力  */
      unsigned long         akey = 0;     /*  非対称(公開鍵)暗号処理能力  */
      unsigned long         sign = 0;     /*  署名処理能力  */
      int                     rc = 0;     /*  返り値  */

      dbg_out("here\n");

      rc = -EINVAL;
      if (message == NULL)
            goto error_out;

      /*
       *  ウィジェット獲得
       */
      window = GTK_WIDGET(create_clientInfoWindow());
      g_assert(window);

      userlabel = GTK_LABEL(lookup_widget(window, "clientInfoUserLabel"));
      g_assert(userlabel);

      typelabel = GTK_LABEL(lookup_widget(window, "clientInfoTypeLabel"));
      g_assert(typelabel);

      text_view = GTK_TEXT_VIEW(lookup_widget(GTK_WIDGET(window), 
            "clientInfoTextview"));
      g_assert(text_view);

      text_buffer = gtk_text_view_get_buffer(text_view);
      g_assert(text_buffer);

      /*
       * 種別判定
       */
      switch(command) {
      case IPMSG_SENDINFO:
            gtk_label_set_text(typelabel, _("Version Information"));
            break;
      case IPMSG_SENDABSENCEINFO:
            gtk_label_set_text(typelabel, _("Absence Information"));
            break;
      default:
            rc = -EINVAL;
            goto error_out;
            break;
      }

      /*
       * 出力メッセージ整形
       */
      rc = convert_string_internal(message, 
          (const gchar **)&internal_message);
      if (internal_message == NULL) {
            ipmsg_err_dialog(_("Can not convert message from %s into ineternal representation"), ipaddr);
            goto error_out;
      }

      len = strlen(internal_message);
      gtk_text_buffer_set_text(text_buffer, internal_message, len);
      g_free(internal_message);

      if (command == IPMSG_SENDABSENCEINFO)
            goto show_out;  /*  不在文の場合は, クライアント情報は必要ない  */

      /*
       * クライアント情報出力
       */
      if ( (user != NULL) && (ipaddr != NULL) ) {
            if (!userdb_search_user_by_addr(ipaddr, 
                  (const userdb_t **)&user_info)) {
                  g_assert(userlabel);

                  snprintf(buffer, 63, "%s@%s (%s)",
                      user_info->nickname, user_info->host, 
                      user_info->group);
                  buffer[63] = '\0';
                  gtk_label_set_text(userlabel, buffer);

                  /*
                   * IPアドレス
                   */
                  client_info_add_text(text_buffer, "\n");
                  client_info_add_text(text_buffer, "%s [%s] : %s\n",
                                   _("IP Address"), 
                                   (user_info->pf == PF_INET) ?
                                   ("IPV4") : ("IPV6"),
                                   user_info->ipaddr);
                  client_info_add_text(text_buffer, "%s : 0x%08x\n", 
                      _("Capability"), (unsigned int)user_info->cap);


                  /*
                   * Dial up
                   */
                  if (user_info->cap & IPMSG_DIALUPOPT)
                        client_info_add_text(text_buffer, 
                            "%s : %s\n", _("Dial up"), _("YES"));
                  else
                        client_info_add_text(text_buffer, 
                            "%s : %s\n", _("Dial up"), _("NO"));
                  /*
                   * UTF-8
                   */
                  if (user_info->cap & IPMSG_UTF8OPT)
                        client_info_add_text(text_buffer, 
                            "%s : %s\n", _("UTF-8"), _("YES"));
                  else
                        client_info_add_text(text_buffer, 
                            "%s : %s\n", _("UTF-8"), _("NO"));
                  /*
                   * File Attach
                   */
                  if (user_info->cap & IPMSG_FILEATTACHOPT)
                        client_info_add_text(text_buffer, 
                            "%s : %s\n", _("File Attach"), _("YES"));
                  else
                        client_info_add_text(text_buffer, 
                            "%s : %s\n", _("File Attach"), _("NO"));

                  /*
                   * Encryption
                   */
                  
                  if (user_info->cap & IPMSG_ENCRYPTOPT) {

                        client_info_add_text(text_buffer, 
                            "%s:%s (%s:0x%08x)\n", 
                            _("Encryption Capability"), _("YES"),
                            _("Capability"), user_info->crypt_cap);
                        
                        akey = get_asymkey_part(user_info->crypt_cap);
                        skey = get_symkey_part(user_info->crypt_cap);
                        sign = get_sign_part(user_info->crypt_cap);

                        /*
                         * Public key
                         */
                        client_info_add_text(text_buffer, 
                            "%s:", _("Public key encryption"));

                        if (akey != 0) {
                              if (akey & IPMSG_RSA_512)
                                    client_info_add_text(text_buffer, "[%s]", _("RSA 512 bits"));

                              if (akey & IPMSG_RSA_1024)
                                    client_info_add_text(text_buffer, "[%s]", _("RSA 1024 bits"));

                              if (akey & IPMSG_RSA_2048)
                                    client_info_add_text(text_buffer, "[%s]", _("RSA 2048 bits"));

                        } else {
                              client_info_add_text(text_buffer, "[%s]", _("UnKnown"));
                        }
                        client_info_add_text(text_buffer, "\n");

                        /*
                         * Symmetric key
                         */

                        client_info_add_text(text_buffer, "%s:",
                            _("Symmetric key encryption"));

                        if (skey != 0) {

                              if (skey & IPMSG_RC2_40)
                                    client_info_add_text(text_buffer, "[%s]", _("RC2 40 bits"));

                              if (skey & IPMSG_RC2_128)
                                    client_info_add_text(text_buffer, "[%s]", _("RC2 128 bits"));

                              if (skey & IPMSG_RC2_256)
                                    client_info_add_text(text_buffer, "[%s]", _("RC2 256 bits"));

                              if (skey & IPMSG_BLOWFISH_128)
                                    client_info_add_text(text_buffer, "[%s]", _("Blowfish 128 bits"));

                              if (skey & IPMSG_BLOWFISH_256)
                                    client_info_add_text(text_buffer, "[%s]", _("Blowfish 256 bits"));

                              if (skey & IPMSG_AES_128)
                                    client_info_add_text(text_buffer, "[%s]", _("AES 128 bits"));

                              if (skey & IPMSG_AES_192)
                                    client_info_add_text(text_buffer, "[%s]", _("AES 192 bits"));

                              if (skey & IPMSG_AES_256)
                                    client_info_add_text(text_buffer, "[%s]", _("AES 256 bits"));


                        } else {
                              client_info_add_text(text_buffer, 
                                  "[%s]", _("UnKnown"));
                        }
                        client_info_add_text(text_buffer, "\n");

                        /*
                         * Signature
                         */
                        client_info_add_text(text_buffer, 
                            "%s:", _("Signature"));

                        if (sign != 0) {

                              if (sign & IPMSG_SIGN_MD5)
                                    client_info_add_text(text_buffer, "[%s]", _("MD5"));

                              if (sign & IPMSG_SIGN_SHA1)
                                    client_info_add_text(text_buffer, "[%s]", _("SHA1"));
                        } else {
                              client_info_add_text(text_buffer, 
                                  "[%s]", _("UnKnown"));
                        }
                        client_info_add_text(text_buffer, "\n");

                  } else {
                        client_info_add_text(text_buffer, 
                            "%s:%s\n", _("Encryption Capability"), 
                            _("NO"));
                  }
            } else {
                  gtk_label_set_text(userlabel, user);
            }
      } else {
            gtk_label_set_text(userlabel, (_("UnKnown")));
      }

show_out:
      gtk_widget_show(window);

      rc=0;

error_out:
      if (user_info != NULL)
            g_assert(!destroy_user_info(user_info));

      if (user != NULL)
            g_free((gchar *)user);

      return rc;
}


Generated by  Doxygen 1.6.0   Back to index