transport: pass correct channel
[abstract.git] / storage / base / aaInsertEntity.cpp
blobd98e3a44a4debc8714da0aa0a1b26bfcf155322d
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 "nsIMutableArray.h"
29 #include "nsISupportsPrimitives.h"
31 /* Unfrozen API */
33 /* Project includes */
34 #include "aaIEntity.h"
35 #include "aaIHandler.h"
36 #include "aaInsertEntity.h"
38 static const char *sql = "INSERT INTO entity (tag) VALUES (?)";
40 aaInsertEntity::aaInsertEntity()
42 mSql = sql;
45 NS_IMPL_ISUPPORTS_INHERITED0(aaInsertEntity,
46 aaSaveRequest)
48 /* aaSaveRequest */
49 NS_IMETHODIMP
50 aaInsertEntity::SetFilter(nsISupports * aFilter)
52 nsresult rv;
53 mEntity = do_QueryInterface(aFilter, &rv);
54 NS_ENSURE_SUCCESS(rv, rv);
56 return NS_OK;
59 NS_IMETHODIMP
60 aaInsertEntity::GetParams(nsIArray * * aParams)
62 NS_ENSURE_ARG_POINTER(aParams);
63 NS_ENSURE_TRUE(mEntity, NS_ERROR_NOT_INITIALIZED);
64 nsresult rv;
66 nsCOMPtr<nsIMutableArray> result
67 = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
68 NS_ENSURE_SUCCESS(rv, rv);
70 nsAutoString wTag;
71 rv = mEntity->GetTag(wTag);
72 NS_ENSURE_SUCCESS(rv, rv);
74 nsCOMPtr<nsISupportsCString> valCString
75 = do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID, &rv);
76 NS_ENSURE_SUCCESS(rv, rv);
77 rv = valCString->SetData(NS_ConvertUTF16toUTF8(wTag));
78 NS_ENSURE_SUCCESS(rv, rv);
79 rv = result->InsertElementAt(valCString, 0, PR_FALSE);
80 NS_ENSURE_SUCCESS(rv, rv);
82 *aParams = result;
83 result.forget();
85 return NS_OK;