examples/lm-change-password.c
author Till Maas <opensource@till.name>
Sat, 31 Oct 2015 08:37:51 +0100
changeset 664 f57b1b61e1fe
parent 518 cdd6a0c5b439
child 690 7ccf2113ec5f
permissions -rw-r--r--
Remove trailing whitespace and mixed indenting
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
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    16
 * License along with this library; if not, write to the
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    17
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    18
 * Boston, MA 02111-1307, USA.
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    19
 */
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    20
664
f57b1b61e1fe Remove trailing whitespace and mixed indenting
Till Maas <opensource@till.name>
parents: 518
diff changeset
    21
/*
85
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    22
 * Small tool to change password on an account
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    23
 */
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    24
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    25
#include <loudmouth/loudmouth.h>
104
f43fde0f89d4 2004-11-08 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 99
diff changeset
    26
#include <string.h>
f43fde0f89d4 2004-11-08 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 99
diff changeset
    27
664
f57b1b61e1fe Remove trailing whitespace and mixed indenting
Till Maas <opensource@till.name>
parents: 518
diff changeset
    28
static LmSSLResponse
104
f43fde0f89d4 2004-11-08 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 99
diff changeset
    29
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
    30
          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
    31
          gpointer      user_data)
104
f43fde0f89d4 2004-11-08 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 99
diff changeset
    32
{
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
    33
    return LM_SSL_RESPONSE_CONTINUE;
104
f43fde0f89d4 2004-11-08 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 99
diff changeset
    34
}
85
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    35
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    36
static void
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    37
print_usage (const gchar *exec_name)
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    38
{
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
    39
    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
    40
             exec_name);
85
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    41
}
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    42
664
f57b1b61e1fe Remove trailing whitespace and mixed indenting
Till Maas <opensource@till.name>
parents: 518
diff changeset
    43
int
85
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    44
main (int argc, char **argv)
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    45
{
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
    46
    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
    47
    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
    48
    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
    49
    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
    50
    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
    51
    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
    52
    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
    53
    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
    54
    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
    55
    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
    56
    gboolean       use_ssl = FALSE;
664
f57b1b61e1fe Remove trailing whitespace and mixed indenting
Till Maas <opensource@till.name>
parents: 518
diff changeset
    57
f57b1b61e1fe Remove trailing whitespace and mixed indenting
Till Maas <opensource@till.name>
parents: 518
diff changeset
    58
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
    59
    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
    60
        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
    61
        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
    62
    }
85
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    63
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
    64
    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
    65
    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
    66
    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
    67
    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
    68
    host = NULL;
85
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    69
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
    70
    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
    71
        int i;
104
f43fde0f89d4 2004-11-08 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 99
diff changeset
    72
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
    73
        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
    74
            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
    75
                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
    76
                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
    77
            }
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
            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
    79
                     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
    80
                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
    81
                    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
    82
                    return -1;
664
f57b1b61e1fe Remove trailing whitespace and mixed indenting
Till Maas <opensource@till.name>
parents: 518
diff changeset
    83
                }
107
aa7e8b466ca8 2005-02-02 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 104
diff changeset
    84
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
    85
                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
    86
                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
    87
            }
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
    88
        }
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
    }
104
f43fde0f89d4 2004-11-08 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 99
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
    connection = lm_connection_new (server);
85
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
    92
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
    93
    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
    94
        gchar *jid;
107
aa7e8b466ca8 2005-02-02 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 104
diff changeset
    95
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
    96
        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
    97
        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
    98
        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
    99
        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
   100
    }
664
f57b1b61e1fe Remove trailing whitespace and mixed indenting
Till Maas <opensource@till.name>
parents: 518
diff changeset
   101
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
   102
    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
   103
        LmSSL *ssl;
104
f43fde0f89d4 2004-11-08 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 99
diff changeset
   104
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
   105
        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
   106
            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
   107
            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
   108
        }
104
f43fde0f89d4 2004-11-08 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 99
diff changeset
   109
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
   110
        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
   111
        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
   112
        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
   113
        lm_ssl_unref (ssl);
104
f43fde0f89d4 2004-11-08 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 99
diff changeset
   114
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
   115
        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
   116
                                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
   117
    }
104
f43fde0f89d4 2004-11-08 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 99
diff changeset
   118
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
   119
    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
   120
        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
   121
    }
85
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
   122
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
    if (!lm_connection_authenticate_and_block (connection,
664
f57b1b61e1fe Remove trailing whitespace and mixed indenting
Till Maas <opensource@till.name>
parents: 518
diff changeset
   124
                                               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
   125
                                               "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
   126
                                               &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
   127
        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
   128
    }
85
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
   129
664
f57b1b61e1fe Remove trailing whitespace and mixed indenting
Till Maas <opensource@till.name>
parents: 518
diff changeset
   130
    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
   131
                                      LM_MESSAGE_SUB_TYPE_SET);
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
    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
   134
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
   135
    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
   136
                                    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
   137
    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
   138
    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
   139
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
   140
    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
   141
    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
   142
        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
   143
    }
107
aa7e8b466ca8 2005-02-02 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 104
diff changeset
   144
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
   145
    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
   146
        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
   147
    } 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
   148
        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
   149
        /* 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
   150
         * 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
   151
    }
664
f57b1b61e1fe Remove trailing whitespace and mixed indenting
Till Maas <opensource@till.name>
parents: 518
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
    lm_connection_close (connection, NULL);
85
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
   154
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
   155
    return 0;
85
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
   156
}
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
   157
cc434baf49cf Added a few files I forget when syncing with svn
hallski <hallski>
parents:
diff changeset
   158