examples/lm-change-password.c
author Mikael Berthe <mikael@lilotux.net>
Sat, 10 Jul 2021 09:37:34 +0200
changeset 743 9098ee1972df
parent 690 7ccf2113ec5f
permissions -rw-r--r--
Merge pull request #43 from ryandesign/patch-1 Fix typo: GnuTSL -> GnuTLS committer: GitHub <noreply@github.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
517
6fabea75bea7 Make the emacs header changes to tests and examples
Mikael Hallendal <micke@imendio.com>
parents: 107
diff changeset
     1
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
85
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
     2
/*
99
81e9d035de02 2004-10-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 85
diff changeset
     3
 * Copyright (C) 2004 Imendio AB
85
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
     4
 *
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
     5
 * This library is free software; you can redistribute it and/or
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
     6
 * modify it under the terms of the GNU Library General Public
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
     7
 * License as published by the Free Software Foundation; either
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
     8
 * version 2 of the License, or (at your option) any later version.
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
     9
 *
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    10
 * This library is distributed in the hope that it will be useful,
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    13
 * Library General Public License for more details.
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    14
 *
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    15
 * You should have received a copy of the GNU Library General Public
690
7ccf2113ec5f Update the postal address of the FSF
Frank Zschockelt <lm@freakysoft.de>
parents: 664
diff changeset
    16
 * License along with this program; if not, see <https://www.gnu.org/licenses>
85
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    17
 */
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    18
664
f57b1b61e1fe Remove trailing whitespace and mixed indenting
Till Maas <opensource@till.name>
parents: 518
diff changeset
    19
/*
85
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    20
 * Small tool to change password on an account
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    21
 */
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    22
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    23
#include <loudmouth/loudmouth.h>
104
f43fde0f89d4 2004-11-08 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 99
diff changeset
    24
#include <string.h>
f43fde0f89d4 2004-11-08 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 99
diff changeset
    25
664
f57b1b61e1fe Remove trailing whitespace and mixed indenting
Till Maas <opensource@till.name>
parents: 518
diff changeset
    26
static LmSSLResponse
104
f43fde0f89d4 2004-11-08 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 99
diff changeset
    27
ssl_func (LmSSL        *ssl,
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    28
          LmSSLStatus   status,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    29
          gpointer      user_data)
104
f43fde0f89d4 2004-11-08 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 99
diff changeset
    30
{
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    31
    return LM_SSL_RESPONSE_CONTINUE;
104
f43fde0f89d4 2004-11-08 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 99
diff changeset
    32
}
85
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    33
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    34
static void
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    35
print_usage (const gchar *exec_name)
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    36
{
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    37
    g_print ("Usage: %s <server> <username> <oldpassword> <newpassword> [--ssl] [--host <host>]\n",
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    38
             exec_name);
85
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    39
}
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    40
664
f57b1b61e1fe Remove trailing whitespace and mixed indenting
Till Maas <opensource@till.name>
parents: 518
diff changeset
    41
int
85
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    42
main (int argc, char **argv)
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    43
{
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    44
    LmConnection  *connection;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    45
    const gchar   *server;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    46
    const gchar   *username;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    47
    const gchar   *old_pass;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    48
    const gchar   *new_pass;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    49
    const gchar   *host;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    50
    GError        *error = NULL;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    51
    LmMessage     *m;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    52
    LmMessage     *reply;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    53
    LmMessageNode *query;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    54
    gboolean       use_ssl = FALSE;
664
f57b1b61e1fe Remove trailing whitespace and mixed indenting
Till Maas <opensource@till.name>
parents: 518
diff changeset
    55
f57b1b61e1fe Remove trailing whitespace and mixed indenting
Till Maas <opensource@till.name>
parents: 518
diff changeset
    56
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    57
    if (argc < 5) {
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    58
        print_usage (argv[0]);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    59
        return -1;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    60
    }
85
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    61
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    62
    server = argv[1];
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    63
    username = argv[2];
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    64
    old_pass = argv[3];
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    65
    new_pass = argv[4];
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    66
    host = NULL;
85
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    67
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    68
    if (argc >= 5) {
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    69
        int i;
104
f43fde0f89d4 2004-11-08 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 99
diff changeset
    70
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    71
        for (i = 5; i < argc; ++i) {
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    72
            if (strcmp (argv[i], "-s") == 0 ||
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    73
                strcmp (argv[i], "--ssl") == 0) {
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    74
                use_ssl = TRUE;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    75
            }
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    76
            else if (strcmp (argv[i], "-h") == 0 ||
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    77
                     strcmp (argv[i], "--host") == 0) {
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    78
                if (++i >= argc) {
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    79
                    print_usage (argv[0]);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    80
                    return -1;
664
f57b1b61e1fe Remove trailing whitespace and mixed indenting
Till Maas <opensource@till.name>
parents: 518
diff changeset
    81
                }
107
aa7e8b466ca8 2005-02-02 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 104
diff changeset
    82
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    83
                host = argv[i];
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    84
                g_print ("HOST: %s\n", host);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    85
            }
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    86
        }
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    87
    }
104
f43fde0f89d4 2004-11-08 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 99
diff changeset
    88
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    89
    connection = lm_connection_new (server);
85
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    90
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    91
    if (host) {
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    92
        gchar *jid;
107
aa7e8b466ca8 2005-02-02 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 104
diff changeset
    93
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    94
        jid = g_strdup_printf ("%s@%s", username, host);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    95
        g_print ("Setting jid to %s\n", jid);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    96
        lm_connection_set_jid (connection, jid);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    97
        g_free (jid);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
    98
    }
664
f57b1b61e1fe Remove trailing whitespace and mixed indenting
Till Maas <opensource@till.name>
parents: 518
diff changeset
    99
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   100
    if (use_ssl) {
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   101
        LmSSL *ssl;
104
f43fde0f89d4 2004-11-08 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 99
diff changeset
   102
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   103
        if (!lm_ssl_is_supported ()) {
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   104
            g_print ("This loudmouth installation doesn't support SSL\n");
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   105
            return 1;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   106
        }
104
f43fde0f89d4 2004-11-08 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 99
diff changeset
   107
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   108
        g_print ("Setting ssl\n");
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   109
        ssl = lm_ssl_new (NULL, ssl_func, NULL, NULL);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   110
        lm_connection_set_ssl (connection, ssl);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   111
        lm_ssl_unref (ssl);
104
f43fde0f89d4 2004-11-08 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 99
diff changeset
   112
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   113
        lm_connection_set_port (connection,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   114
                                LM_CONNECTION_DEFAULT_PORT_SSL);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   115
    }
104
f43fde0f89d4 2004-11-08 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 99
diff changeset
   116
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   117
    if (!lm_connection_open_and_block (connection, &error)) {
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   118
        g_error ("Failed to open: %s\n", error->message);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   119
    }
85
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
   120
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   121
    if (!lm_connection_authenticate_and_block (connection,
664
f57b1b61e1fe Remove trailing whitespace and mixed indenting
Till Maas <opensource@till.name>
parents: 518
diff changeset
   122
                                               username, old_pass,
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   123
                                               "Password changer",
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   124
                                               &error)) {
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   125
        g_error ("Failed to authenticate: %s\n", error->message);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   126
    }
85
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
   127
664
f57b1b61e1fe Remove trailing whitespace and mixed indenting
Till Maas <opensource@till.name>
parents: 518
diff changeset
   128
    m = lm_message_new_with_sub_type (NULL, LM_MESSAGE_TYPE_IQ,
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   129
                                      LM_MESSAGE_SUB_TYPE_SET);
664
f57b1b61e1fe Remove trailing whitespace and mixed indenting
Till Maas <opensource@till.name>
parents: 518
diff changeset
   130
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   131
    query = lm_message_node_add_child (m->node, "query", NULL);
664
f57b1b61e1fe Remove trailing whitespace and mixed indenting
Till Maas <opensource@till.name>
parents: 518
diff changeset
   132
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   133
    lm_message_node_set_attributes (query, "xmlns", "jabber:iq:register",
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   134
                                    NULL);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   135
    lm_message_node_add_child (query, "username", username);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   136
    lm_message_node_add_child (query, "password", new_pass);
107
aa7e8b466ca8 2005-02-02 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 104
diff changeset
   137
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   138
    reply = lm_connection_send_with_reply_and_block (connection, m, &error);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   139
    if (!reply) {
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   140
        g_error ("Failed to change password: %s\n", error->message);
664
f57b1b61e1fe Remove trailing whitespace and mixed indenting
Till Maas <opensource@till.name>
parents: 518
diff changeset
   141
    }
107
aa7e8b466ca8 2005-02-02 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 104
diff changeset
   142
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   143
    if (lm_message_get_sub_type (reply) == LM_MESSAGE_SUB_TYPE_RESULT) {
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   144
        g_print ("Password changed\n");
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   145
    } else {
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   146
        g_print ("Failed to change password\n");
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   147
        /* If this wasn't only an example we should check error code
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   148
         * here to tell the user why it failed */
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   149
    }
664
f57b1b61e1fe Remove trailing whitespace and mixed indenting
Till Maas <opensource@till.name>
parents: 518
diff changeset
   150
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   151
    lm_connection_close (connection, NULL);
85
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
   152
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 517
diff changeset
   153
    return 0;
85
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
   154
}
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
   155
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
   156