transport: pass correct channel
[abstract.git] / storage / base / aaInsertMoney.cpp
blob2eb620c2feb3e793926e017eb6cd3d8ffd63da36
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent tw=79 ft=cpp: */
3 /*
4 * Copyright (C) 2008 Sergey Yanovich <ynvich@gmail.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public
17 * License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
22 #include "xpcom-config.h"
24 #include "nsCOMPtr.h"
25 #include "nsStringAPI.h"
26 #include "nsComponentManagerUtils.h"
27 #include "nsXPCOMCID.h"
28 #include "nsISupportsPrimitives.h"
29 #include "nsIMutableArray.h"
31 /* Unfrozen API */
33 /* Project includes */
34 #include "aaIMoney.h"
35 #include "aaInsertMoney.h"
37 static const char *sql = "INSERT INTO money (id,alpha_code) VALUES (?,?)";
39 aaInsertMoney::aaInsertMoney()
41 mSql = sql;
44 NS_IMPL_ISUPPORTS_INHERITED0(aaInsertMoney,
45 aaSaveRequest)
47 /* aaSaveRequest */
48 NS_IMETHODIMP
49 aaInsertMoney::SetFilter(nsISupports * aFilter)
51 nsresult rv;
52 mMoney = do_QueryInterface(aFilter, &rv);
53 NS_ENSURE_SUCCESS(rv, rv);
55 return NS_OK;
58 NS_IMETHODIMP
59 aaInsertMoney::GetParams(nsIArray * * aParams)
61 NS_ENSURE_ARG_POINTER(aParams);
62 NS_ENSURE_TRUE(mMoney, NS_ERROR_NOT_INITIALIZED);
63 nsresult rv;
65 nsCOMPtr<nsIMutableArray> result
66 = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
67 NS_ENSURE_SUCCESS(rv, rv);
69 nsAutoString wTag;
70 rv = mMoney->GetTag(wTag);
71 NS_ENSURE_SUCCESS(rv, rv);
73 nsCOMPtr<nsISupportsPRInt64> valInt64
74 = do_CreateInstance(NS_SUPPORTS_PRINT64_CONTRACTID, &rv);
75 NS_ENSURE_SUCCESS(rv, rv);
76 rv = valInt64->SetData(mMoney->PickId());
77 NS_ENSURE_SUCCESS(rv, rv);
78 rv = result->InsertElementAt(valInt64, 0, PR_FALSE);
79 NS_ENSURE_SUCCESS(rv, rv);
81 nsCOMPtr<nsISupportsCString> valCString
82 = do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID, &rv);
83 NS_ENSURE_SUCCESS(rv, rv);
84 rv = valCString->SetData(NS_ConvertUTF16toUTF8(wTag));
85 NS_ENSURE_SUCCESS(rv, rv);
86 rv = result->InsertElementAt(valCString, 1, PR_FALSE);
87 NS_ENSURE_SUCCESS(rv, rv);
89 *aParams = result;
90 result.forget();
92 return NS_OK;