📄 alarm.cpp
字号:
TAreaCode aAreaCode = iOplAPI.PopString();
TInt32 aLong = iOplAPI.PopInt32();
TInt32 aLat = iOplAPI.PopInt32();
TCityName aCityName = iOplAPI.PopString();
// Get Country Info
TIntlPrefCode aInternationalPrefixCode = iOplAPI.PopString();
TNatPrefCode aNationalPrefixCode = iOplAPI.PopString();
TNatCode aNationalCode = iOplAPI.PopString();
TCountryName aCountryName = iOplAPI.PopString();
// Setup country info
TCountryData countryData;
countryData.iCountry = aCountryName;
countryData.iNatCode = aNationalCode;
countryData.iCapital = aCityName;
countryData.iNatPref = aNationalPrefixCode;
countryData.iIntlPref = aInternationalPrefixCode;
// Setup capital city info
TLatLong latLong;
latLong.SetMinutesL(aLat,aLong);
TCityData cityData;
cityData.iCity = aCityName;
cityData.iMapPos = TPoint(aMapX,aMapY);
cityData.iCountry = aCountryName;
cityData.iLatLong = latLong;
cityData.iAreaCode = aAreaCode;
cityData.iDaylightSavingZone = aDaylightZone;
cityData.iUniversalTimeOffset = aGMTOffset;
// Add country (and new capital city) to database
RWorldServer worldServer;
User::LeaveIfError(worldServer.Connect());
User::LeaveIfError(worldServer.AddCountry(countryData, cityData));
worldServer.Close();
iOplAPI.Push(0.0);
}
void COpxAlarm::EditCity() const
//
// WldEditCity:(aCityToEdit$, aCountryToEdit$, aCityName$, aCountryName$, aMinsLat&,
// aMinsLong&, aAreaCode$, aDaylightZone%, aGMTOffset&, aMapX%, aMapY%) : 19
//
{
// Get city info
TInt32 aMapY = iOplAPI.PopInt16();
TInt32 aMapX = iOplAPI.PopInt16();
TInt32 aGMTOffset = iOplAPI.PopInt32();
TDaylightSavingZone aDaylightZone = STATIC_CAST(TDaylightSavingZone,iOplAPI.PopInt16());
TAreaCode aAreaCode = iOplAPI.PopString();
TInt32 aLong = iOplAPI.PopInt32();
TInt32 aLat = iOplAPI.PopInt32();
TCountryName aCountryName = iOplAPI.PopString();
TCityName aCityName = iOplAPI.PopString();
TCountryName aCountryToEdit = iOplAPI.PopString();
TCityName aCityToEdit = iOplAPI.PopString();
// Setup city info
TLatLong latLong;
latLong.SetMinutesL(aLat,aLong);
TCityData cityData;
cityData.iCity = aCityName;
cityData.iMapPos = TPoint(aMapX,aMapY);
cityData.iCountry = aCountryName;
cityData.iLatLong = latLong;
cityData.iAreaCode = aAreaCode;
cityData.iDaylightSavingZone = aDaylightZone;
cityData.iUniversalTimeOffset = aGMTOffset;
// Update city
RWorldServer worldServer;
TWorldId worldId;
User::LeaveIfError(worldServer.Connect());
User::LeaveIfError(worldServer.Find(worldId, aCityToEdit, aCountryToEdit));
User::LeaveIfError(worldServer.UpdateCity(worldId, cityData));
worldServer.Close();
iOplAPI.Push(0.0); // returns nothing
}
void COpxAlarm::EditCountry() const
//
// WldEditCountry:(aCountryToEdit$, aCountryName$, aNationalCode$, aNationalPrefix$,
// aInternationalPrefix$, aCapitalCity$) : 20
//
{
// Get Country Info
TCityName aCityName = iOplAPI.PopString();
TIntlPrefCode aInternationalPrefixCode = iOplAPI.PopString();
TNatPrefCode aNationalPrefixCode = iOplAPI.PopString();
TNatCode aNationalCode = iOplAPI.PopString();
TCountryName aCountryName = iOplAPI.PopString();
TCountryName aCountryToEdit = iOplAPI.PopString();
// Setup country info
TCountryData countryData;
countryData.iCountry = aCountryName;
countryData.iNatCode = aNationalCode;
countryData.iCapital = aCityName;
countryData.iNatPref = aNationalPrefixCode;
countryData.iIntlPref = aInternationalPrefixCode;
// Update city
RWorldServer worldServer;
TWorldId worldId;
User::LeaveIfError(worldServer.Connect());
User::LeaveIfError(worldServer.FindCountry(worldId, aCountryToEdit));
User::LeaveIfError(worldServer.UpdateCountry(worldId, countryData));
worldServer.Close();
iOplAPI.Push(0.0); // returns nothing
}
void COpxAlarm::DeleteCity() const
//
// WldDeleteCity:(aCityName$, aCountryName$) : 21
//
{
TCountryName aCountryName = iOplAPI.PopString();
TCityName aCityName = iOplAPI.PopString();
RWorldServer worldServer;
TWorldId worldId;
User::LeaveIfError(worldServer.Connect());
User::LeaveIfError(worldServer.Find(worldId, aCityName, aCountryName));
User::LeaveIfError(worldServer.DeleteCity(worldId));
worldServer.Close();
iOplAPI.Push(0.0); // returns nothing
}
void COpxAlarm::DeleteCountry() const
//
// WldDeleteCountry:(aCountryName$) : 22
//
{
TCountryName aCountryName = iOplAPI.PopString();
RWorldServer worldServer;
TWorldId worldId;
User::LeaveIfError(worldServer.Connect());
User::LeaveIfError(worldServer.FindCountry(worldId, aCountryName));
User::LeaveIfError(worldServer.DeleteCountry(worldId));
worldServer.Close();
iOplAPI.Push(0.0); // returns nothing
}
void COpxAlarm::NumberOfCities() const
//
// WldNumberOfCities&: : 23
//
{
RWorldServer worldServer;
User::LeaveIfError(worldServer.Connect());
TInt32 noCities = worldServer.NumberCities();
// User::LeaveIfError(noCities);
worldServer.Close();
iOplAPI.Push(noCities); // returns result of the NumberCities() call
}
void COpxAlarm::NumberOfCountries() const
//
// WldNumberOfCountries&: : 24
//
{
RWorldServer worldServer;
User::LeaveIfError(worldServer.Connect());
TInt32 noCountries = worldServer.NumberCountries();
// User::LeaveIfError(noCountries);
worldServer.Close();
iOplAPI.Push(noCountries); // returns result of the NumberCountries() call
}
void COpxAlarm::SaveDataFile() const
//
// WldDataFileSave: : 25
//
{
RWorldServer worldServer;
User::LeaveIfError(worldServer.Connect());
User::LeaveIfError(worldServer.DataFileSave());
worldServer.Close();
iOplAPI.Push(0.0); // returns nothing
}
void COpxAlarm::RevertDataFile() const
//
// WldDataFileRevert: : 26
//
{
RWorldServer worldServer;
User::LeaveIfError(worldServer.Connect());
// This should leave with 'Does not exist' in OPL if no data RAM file exists
User::LeaveIfError(worldServer.DataFileRevertToSaved());
User::LeaveIfError(worldServer.DataFileSave()); // does it need saving after revert? Leave in just to be safe :-)
worldServer.Close();
iOplAPI.Push(0.0); // returns nothing
}
/*
void COpxAlarm::DataFileLocation() const
//
// WldDataFileLocation$: : 27
//
{
RWorldServer worldServer;
User::LeaveIfError(worldServer.Connect());
TFileName dataFile;
User::LeaveIfError(worldServer.DataFileLocation(dataFile));
worldServer.Close();
iOplAPI.PushL(dataFile); // returns data file location
}
void COpxAlarm::ResetAllData() const
//
// WldDataFileReset: : 28
//
{
RWorldServer worldServer;
User::LeaveIfError(worldServer.Connect());
User::LeaveIfError(worldServer.ResetAllData());
worldServer.Close();
iOplAPI.Push(0.0); // returns nothing
}
*/
//////////////////////////////////////////////////////////////////////////
// The members of COpxAlarm which are not language extension procedures //
//////////////////////////////////////////////////////////////////////////
COpxAlarm::COpxAlarm(OplAPI& aOplAPI)
:COpxBase(aOplAPI)
{
}
COpxAlarm* COpxAlarm::NewLC(OplAPI& aOplAPI)
{
COpxAlarm* This=new(ELeave) COpxAlarm(aOplAPI);
CleanupStack::PushL(This);
This->ConstructL();
return This;
}
void COpxAlarm::ConstructL()
{
}
COpxAlarm::~COpxAlarm()
// Required so that Tls is set to zero on unloading the OPX
{
Dll::FreeTls();
}
////////////////////////////////
// Implementation of COpxBase //
////////////////////////////////
void COpxAlarm::RunL(TInt aProcNum)
// Run a language extension procedure
{
switch (aProcNum)
{
case ESetClockAlarm:
SetClockAlarm();
break;
case EAlarmState:
AlarmState();
break;
case EAlarmEnable:
AlarmEnable();
break;
case EAlarmDelete:
AlarmDelete();
break;
case EQuietPeriodCancel:
QuietPeriodCancel();
break;
case EQuietPeriodUntil:
QuietPeriodUntil();
break;
case EQuietPeriodSet:
QuietPeriodSet();
break;
case ESetAlarmSoundOn:
SetAlarmSoundOn();
break;
case EAlarmSoundState:
AlarmSoundState();
break;
case EFindCity:
FindCity();
break;
case ESunlight:
Sunlight();
break;
case EHome:
Home();
break;
case EPreviousCity:
case ENextCity:
MoveCity(aProcNum);
break;
case EPreviousCountry:
case ENextCountry:
MoveCountry(aProcNum);
break;
case EAddCity:
AddCity();
break;
case EAddCountry:
AddCountry();
break;
case EEditCity:
EditCity();
break;
case EEditCountry:
EditCountry();
break;
case EDeleteCity:
DeleteCity();
break;
case EDeleteCountry:
DeleteCountry();
break;
case ENumberOfCities:
NumberOfCities();
break;
case ENumberOfCountries:
NumberOfCountries();
break;
case ESaveDataFile:
SaveDataFile();
break;
case ERevertDataFile:
RevertDataFile();
break;
/* case EDataFileLocation:
DataFileLocation();
break;
case EResetDataFile:
ResetAllData();
break;
*/ default:
User::Leave(KOplErrOpxProcNotFound);
}
}
TBool COpxAlarm::CheckVersion(TInt aVersion)
// To check whether the opx is a compatible version
{
if ((aVersion & 0xFF00)>(KOpxVersion & 0xFF00))
return EFalse; // Bad version
else
return ETrue; // OK
}
EXPORT_C COpxBase* NewOpxL(OplAPI& aOplAPI)
// Creates a COpxBase instance as required by the OPL runtime
// This object is to be stored in the OPX's TLS as shown below
{
COpxAlarm* tls=((COpxAlarm*)Dll::Tls());
// tls is NULL on loading an OPX DLL (also after unloading it)
if (tls==NULL)
{
tls=COpxAlarm::NewLC(aOplAPI);
User::LeaveIfError(Dll::SetTls(tls));
CleanupStack::Pop(); // tls
}
return (COpxBase*)tls;
}
EXPORT_C TUint Version()
{
return KOpxVersion;
}
GLDEF_C TInt E32Dll(TDllReason /*aReason*/)
// DLL entry point
{
return(KErrNone);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -