コード例 #1
0
NS_IMETHODIMP nsMsgFolderCache::GetCacheElement(const nsACString& pathKey, PRBool createIfMissing,
                                                nsIMsgFolderCacheElement **result)
{
  NS_ENSURE_ARG_POINTER(result);
  NS_ENSURE_TRUE(!pathKey.IsEmpty(), NS_ERROR_FAILURE);

  nsCOMPtr<nsIMsgFolderCacheElement> folderCacheEl;
  m_cacheElements.Get(pathKey, getter_AddRefs(folderCacheEl));
  folderCacheEl.swap(*result);

  if (*result)
    return NS_OK;
  else if (createIfMissing)
  {
    nsIMdbRow* hdrRow;

    if (GetStore())
    {
      mdb_err err = GetStore()->NewRow(GetEnv(), m_folderRowScopeToken,   // row scope for row ids
        &hdrRow);
      if (NS_SUCCEEDED(err) && hdrRow)
      {
        m_mdbAllFoldersTable->AddRow(GetEnv(), hdrRow);
        nsresult ret = AddCacheElement(pathKey, hdrRow, result);
        if (*result)
          (*result)->SetStringProperty("key", pathKey);
        hdrRow->Release();
        return ret;
      }
    }
  }
  return NS_ERROR_FAILURE;
}
コード例 #2
0
ファイル: LocationDlg.cpp プロジェクト: kamalsirsa/vtp
void LocationDlg::RefreshButtons()
{
	int num = m_pLocList->GetSelection();
	GetStore()->Enable(num != -1);
	GetRecall()->Enable(num != -1);
	GetRemove()->Enable(num != -1);
}
コード例 #3
0
ファイル: datalist.cpp プロジェクト: tchv71/StartPP
void DataModelListCtrl::Fill()
{
#if USE_DATALISTVIEW
    GetStore()->Reset(GetItemCount());
#else
    SetItemCount(GetModel() ? GetModel()->GetRowCount() : 0);
    Refresh();
#endif
}
コード例 #4
0
ファイル: store_loader.cpp プロジェクト: madf/stg
bool STORE_LOADER::Load()
{
if (isLoaded)
    {
    errorStr = "Store plugin '" + pluginFileName + "' was already loaded!";
    printfd(__FILE__, "STORE_LOADER::Load() - %s\n", errorStr.c_str());
    return false;
    }

if (pluginFileName.empty())
    {
    errorStr = "Empty store plugin filename";
    printfd(__FILE__, "STORE_LOADER::Load() - %s\n", errorStr.c_str());
    return true;
    }

handle = dlopen(pluginFileName.c_str(), RTLD_NOW);

if (!handle)
    {
    errorStr = "Error loading plugin '"
        + pluginFileName + "': '" + dlerror() + "'";
    printfd(__FILE__, "STORE_LOADER::Load() - %s\n", errorStr.c_str());
    return true;
    }

isLoaded = true;

STORE * (*GetStore)();
GetStore = (STORE * (*)())dlsym(handle, "GetStore");
if (!GetStore)
    {
    errorStr = std::string("GetStore() not found! ") + dlerror();
    printfd(__FILE__, "STORE_LOADER::Load() - %s\n", errorStr.c_str());
    return true;
    }

plugin = GetStore();

if (!plugin)
    {
    errorStr = "Plugin was not created!";
    printfd(__FILE__, "STORE_LOADER::Load() - %s\n");
    return true;
    }

plugin->SetSettings(storeSettings);
if (plugin->ParseSettings())
    {
    errorStr = plugin->GetStrError();
    printfd(__FILE__, "STORE_LOADER::Load() - Failed to parse settings. Plugin reports: '%s'\n", errorStr.c_str());
    return true;
    }

return false;
}
コード例 #5
0
// initialize the various tokens and tables in our db's env
nsresult nsMsgFolderCache::InitMDBInfo()
{
  nsresult err = NS_OK;
  if (GetStore())
  {
    err = GetStore()->StringToToken(GetEnv(), kFoldersScope, &m_folderRowScopeToken);
    if (NS_SUCCEEDED(err))
    {
      err = GetStore()->StringToToken(GetEnv(), kFoldersTableKind, &m_folderTableKindToken);
      if (NS_SUCCEEDED(err))
      {
        // The table of all message hdrs will have table id 1.
        m_allFoldersTableOID.mOid_Scope = m_folderRowScopeToken;
        m_allFoldersTableOID.mOid_Id = 1;
      }
    }
  }
  return err;
}
コード例 #6
0
ファイル: Persistence.cpp プロジェクト: Booley/nbis
		void Persistence::Store(QWidget* widget, QString storageName) {
			if (storageName.isEmpty()) storageName = widget->objectName();
			if (qobject_cast<QLineEdit*>(widget)) {
				QLineEdit* lineEdit = qobject_cast<QLineEdit*>(widget); 
				GetStore()[storageName] = QVariant(lineEdit->text());
			} else if (qobject_cast<QCheckBox*>(widget)) {
				QCheckBox* cb = qobject_cast<QCheckBox*>(widget); 
				GetStore()[storageName] = QVariant(cb->isChecked());
			} else if (qobject_cast<QSpinBox*>(widget)) {
				QSpinBox* sb = qobject_cast<QSpinBox*>(widget); 
				GetStore()[storageName] = QVariant(sb->value());
			} else if (qobject_cast<QRadioButton*>(widget)) {
				QRadioButton* rb = qobject_cast<QRadioButton*>(widget); 
				GetStore()[storageName] = QVariant(rb->isChecked());
			} else if (qobject_cast<QComboBox*>(widget)) {
				QComboBox* cb = qobject_cast<QComboBox*>(widget); 
				GetStore()[storageName] = QVariant(cb->currentText());
			} else {
				WARNING("Unsupported widget: " + widget->objectName());
			}
		}
コード例 #7
0
ファイル: Persistence.cpp プロジェクト: Booley/nbis
		void Persistence::Restore(QWidget* widget, QString storageName) {
			if (storageName.isEmpty()) storageName = widget->objectName();
			if (qobject_cast<QLineEdit*>(widget)) {
				QLineEdit* lineEdit = qobject_cast<QLineEdit*>(widget); 
				if (GetStore().contains(storageName)) {
					lineEdit->setText(GetStore()[storageName].toString());
				}

			} else if (qobject_cast<QCheckBox*>(widget)) {
				QCheckBox* cb = qobject_cast<QCheckBox*>(widget); 
				if (GetStore().contains(storageName)) {
					cb->setChecked(GetStore()[storageName].toBool());
				}

			} else if (qobject_cast<QSpinBox*>(widget)) {
				QSpinBox* sb = qobject_cast<QSpinBox*>(widget); 
				if (GetStore().contains(storageName)) {
					sb->setValue(GetStore()[storageName].toInt());
				}

			} else if (qobject_cast<QRadioButton*>(widget)) {
				QRadioButton* rb = qobject_cast<QRadioButton*>(widget); 
				if (GetStore().contains(storageName)) {
					rb->setChecked(GetStore()[storageName].toInt());
				}

			} else if (qobject_cast<QComboBox*>(widget)) {
				QComboBox* rb = qobject_cast<QComboBox*>(widget); 
				if (GetStore().contains(storageName)) {
					int i = rb->findText(GetStore()[storageName].toString());
					if (i!=-1) {
						rb->setCurrentIndex(i);
					} else {
					}
				}

			} else {
				WARNING("Unsupported widget: " + widget->objectName());
			}
		}
コード例 #8
0
// set up empty tables, dbFolderInfo, etc.
nsresult nsMsgFolderCache::InitNewDB()
{
  nsresult err = InitMDBInfo();
  if (NS_SUCCEEDED(err))
  {
    nsIMdbStore *store = GetStore();
    // create the unique table for the dbFolderInfo.
    mdb_err mdberr;
    mdberr = (nsresult) store->NewTable(GetEnv(), m_folderRowScopeToken,
    m_folderTableKindToken, PR_FALSE, nsnull, &m_mdbAllFoldersTable);
  }
  return err;
}
コード例 #9
0
// set up empty tables, dbFolderInfo, etc.
nsresult nsMsgFolderCache::InitNewDB()
{
  nsresult err = InitMDBInfo();
  if (NS_SUCCEEDED(err))
  {
    nsIMdbStore *store = GetStore();
    // create the unique table for the dbFolderInfo.
    mdb_err mdberr;
    // TODO: this error assignment is suspicious and never checked.
    mdberr = (nsresult) store->NewTable(GetEnv(), m_folderRowScopeToken,
    m_folderTableKindToken, false, nullptr, &m_mdbAllFoldersTable);
  }
  return err;
}
コード例 #10
0
ファイル: qminer_core.hpp プロジェクト: bergloman/qminer
TVec<PRecSet> TRecSet::SplitBy(const TSplitter& Splitter) const {
    TRecSetV ResV;
    // if no records, nothing to do
    if (Empty()) { return ResV; }
    // initialize with the first record
    TUInt64IntKdV NewRecIdFqV; NewRecIdFqV.Add(RecIdFqV[0]);
    // go over the rest and see when to split
    for (int RecN = 1; RecN < GetRecs(); RecN++) {
        if (Splitter(RecIdFqV[RecN-1], RecIdFqV[RecN])) {
            // we need to split, first we create record set for all existing records
            ResV.Add(TRecSet::New(Store, NewRecIdFqV));
            // and initialize a new one
            NewRecIdFqV.Clr(false);
        }
        // add new record to the next record set
        NewRecIdFqV.Add(RecIdFqV[RecN]);
    }
    // add last record set to the result list
    ResV.Add(TRecSet::New(GetStore(), NewRecIdFqV));
    // done
    return ResV;
}
コード例 #11
0
nsresult nsMsgFolderCache::InitExistingDB()
{
  nsresult err = InitMDBInfo();
  if (NS_FAILED(err))
    return err;

  err = GetStore()->GetTable(GetEnv(), &m_allFoldersTableOID, &m_mdbAllFoldersTable);
  if (NS_SUCCEEDED(err) && m_mdbAllFoldersTable)
  {
    nsIMdbTableRowCursor* rowCursor = nsnull;
    err = m_mdbAllFoldersTable->GetTableRowCursor(GetEnv(), -1, &rowCursor);
    if (NS_SUCCEEDED(err) && rowCursor)
    {
      // iterate over the table rows and create nsMsgFolderCacheElements for each.
      while (PR_TRUE)
      {
        nsresult rv;
        nsIMdbRow* hdrRow;
        mdb_pos rowPos;

        rv = rowCursor->NextRow(GetEnv(), &hdrRow, &rowPos);
        if (NS_FAILED(rv) || !hdrRow)
          break;

        rv = AddCacheElement(EmptyCString(), hdrRow, nsnull);
        hdrRow->Release();
        if (NS_FAILED(rv))
          return rv;
      }
      rowCursor->Release();
    }
  }
  else
    err = NS_ERROR_FAILURE;

  return err;
}
コード例 #12
0
ファイル: Persistence.cpp プロジェクト: Booley/nbis
		void Persistence::Put(QString storageName, QVariant value) {
			GetStore()[storageName] = value;
		}
コード例 #13
0
ファイル: Persistence.cpp プロジェクト: Booley/nbis
		QVariant Persistence::Get(QString storageName) {
			return GetStore()[storageName];
		}
コード例 #14
0
ファイル: Persistence.cpp プロジェクト: Booley/nbis
		bool Persistence::Contains(QString storageName) {
			return GetStore().contains(storageName);
		}