📄 bluejackxcontainer.cpp
字号:
/*
* ============================================================================
* Name : CBlueJackXContainer from BlueJackXContainer.h
* Part of : BlueJackX
* Created : 25.01.2004 by
* Implementation notes:
* Initial content was generated by Series 60 AppWizard.
* Version :
* Copyright:
* ============================================================================
*/
// INCLUDE FILES
#include "BlueJackXContainer.h"
#include <eiklabel.h> // for example label control
#include <aknnotewrappers.h>
#include <aknmessagequerydialog.h>
// f黵 convert to unicode
#include <utf.h>
// ================= MEMBER FUNCTIONS =======================
TPtrC ExtractToken(TLex& aLex, const TChar aSeparator)
{
aLex.Mark();
while (!aLex.Eos() && aLex.Peek() != aSeparator)
{
aLex.Inc();
}
TPtrC result = aLex.MarkedToken();
aLex.Inc();
return result;
}
TPtrC ExtractToken2(TLex& aLex, const TChar aSeparator)
{
aLex.Mark();
while (!aLex.Eos() && aLex.Peek() != aSeparator)
{
aLex.Inc();
}
TPtrC result = aLex.MarkedToken();
aLex.Inc();
return result;
}
// ------------------ CONSTRUCTOR ---------------------
// ----------------------------------------------------
void CBlueJackXContainer::ConstructL(const TRect& aRect)
{
// f黵 zugriff vom container auf die appui
pApp=(CBlueJackXAppUi*)iEikonEnv->AppUi();
CreateWindowL();
SetRect(aRect);
ActivateL();
//Listboxerzeugen
//hier wird die liste erzeugt
iListBox = new (ELeave) CAknDoubleStyleListBox;
iListBox->ConstructL( this, EAknListBoxSelectionList);
iListBox->SetRect(aRect.Size()); // Liste wird auf den gesammten bildschirm vergr鲞ert
iListBox->CreateScrollBarFrameL(ETrue);
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
iListBox->ActivateL();
iListBox->Reset();
itemList = iListBox->Model()->ItemTextArray();
itemArray = (CDesCArray*) itemList;
iListBox->HandleItemAdditionL();
iListBox->DrawNow(); // listbox wird ausgegeben
//ende listbox
STOP = true;
//Datums Array
iItemArray_Stamp = new (ELeave) CDesCArrayFlat(1);
// array f黵 Mac IDs
iItemArray_MacID = new (ELeave) CDesCArrayFlat(1);
// array der den Firmennamen h鋖t
iItemArray_Firma = new (ELeave) CDesCArrayFlat(1);
// nick
iItemArray_Nick = new (ELeave) CDesCArrayFlat(1);
/*
//------------- Test eintrag f黵 emulator -------
//Log beispiel
_LIT16(meinstring3,"Striker");
TBuf16<30> str3(meinstring3);
//nick
iItemArray_Nick->AppendL(str3);
TBuf16<80> str35;
str35+=_L("\t");
str35+=str3;
str35+=_L("\t09.05.2001 - 03:26:00");
itemArray->AppendL(str35);
// uhrzeit auslesen
TTime homeTime;
TBuf<40> uhrzeit;
homeTime.HomeTime();
_LIT(KFormatTxt,"%-B%:0%J%:1%T%:2%S%:3%");
homeTime.FormatL(uhrzeit,KFormatTxt);
// datum holen
TBuf<40> datum;
_LIT(KFormatTxt3,"%/0%1%/1%2%/2%3%/3");
homeTime.FormatL(datum,KFormatTxt3);
TBuf<40> datum_und_uhrzeit;
datum_und_uhrzeit = datum;
datum_und_uhrzeit+=_L(" - ");
datum_und_uhrzeit+=uhrzeit;
// datum speichern
iItemArray_Stamp->AppendL(datum_und_uhrzeit);
iItemArray_MacID->AppendL(_L("ff:ff:ff:ff:ff:ff"));
iItemArray_Firma->AppendL(_L("Ericsson"));
//------------- Test eintrag Ende ----
*/
// Listbox ausgeben
iListBox->HandleItemAdditionL();
iListBox->DrawNow();
Zahl = 1;
iTimer=CPeriodic::NewL( CActive::EPriorityStandard ); //##########
}
// ------------------- DESTRUCTOR ---------------------
// ----------------------------------------------------
CBlueJackXContainer::~CBlueJackXContainer()
{
// entferne status objekte
delete (CBase*) iNaviDecorator;
delete iItemArray_Stamp;
delete iItemArray_MacID;
delete iItemArray_Firma;
delete iItemArray_Nick;
delete iTimer;
delete iListBox; // buddy liste
iListBox = NULL; // buddy liste
}
// ----------------------------------------------------
// ----------------------------------------------------
void CBlueJackXContainer::SizeChanged()
{
}
// ----------------------------------------------------
// ----------------------------------------------------
TInt CBlueJackXContainer::CountComponentControls() const
{
if (iListBox)return 1;
return 0; // return nbr of controls inside this container
}
// ----------------------------------------------------
// ----------------------------------------------------
CCoeControl* CBlueJackXContainer::ComponentControl(TInt aIndex) const
{
switch ( aIndex )
{
case 0:
if (iListBox) return iListBox;
default:
return NULL;
}
}
// ----------------------------------------------------
// ----------------------------------------------------
void CBlueJackXContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
gc.SetPenStyle(CGraphicsContext::ENullPen);
gc.SetBrushColor(KRgbGray);
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.DrawRect(aRect);
}
// ----------------------------------------------------
// ----------------------------------------------------
void CBlueJackXContainer::HandleControlEventL(CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
}
int CBlueJackXContainer::verschickteVCards()
{
TInt Zahl;
Zahl = itemArray->Count();
return Zahl;
}
// ----------------------------------------------------
// ----------------------------------------------------
void CBlueJackXContainer::BuddyHinzufuegen(TBufC<40> BTname,TBTDevAddr MacID)
{
// nick
TBuf16<40> str;
str+=(BTname);
// pr黤t vor dem hinzuf黦en ob der nick mit der mac id schon einmal in der liste ist wenn nicht adden
// dient dazu auch ein ger鋞 ein weiteresmal zu finden wenn der name ge鋘dert ist bzw 2 verschiedene
// macs den sleben namen haben
TBuf<65> MacIdAlsString;
MacIdAlsString = pApp->DezimalMacIDtoString(MacID);
TBuf16<65> str2;
str2+=(MacIdAlsString);
TInt pos2;
TInt RetVal2 = iItemArray_MacID->Find(str2,pos2);
TInt pos;
TInt RetVal = iItemArray_Nick->Find(str,pos);
TInt check;
check = RetVal+RetVal2;
//hinzuf黦en wenn noch nicht in liste
//if(RetVal==0)
if(check==0)
{
// do not add to listbox
}else{
// ############################################################
// Benachrichtigung an Benutzer ausgeben durch Piepsen oder Vibration.
// ############################################################
// uhrzeit auslesen
TTime homeTime;
TBuf<40> uhrzeit;
homeTime.HomeTime();
_LIT(KFormatTxt,"%-B%:0%J%:1%T%:2%S%:3%");
homeTime.FormatL(uhrzeit,KFormatTxt);
// datum holen
TBuf<32> datum;
_LIT(KFormatTxt3,"%/0%1%/1%2%/2%3%/3 ");
homeTime.FormatL(datum,KFormatTxt3);
TBuf<32> datum_und_uhrzeit;
datum_und_uhrzeit = datum;
datum_und_uhrzeit+=_L(" - ");
datum_und_uhrzeit+=uhrzeit;
// add to listbox array mit datumsanzeige
iItemArray_Nick->AppendL(str);
TBuf16<80> str35;
str35+=_L("\t");
str35+=str;
str35+=_L("\t");
str35+=datum_und_uhrzeit;
TInt laenge;
laenge = str35.Length();
itemArray->AppendL(str35.Left(laenge-1));
//listbox ausgeben
iListBox->HandleItemAdditionL();
iListBox->DrawNow();
// datum speichern
iItemArray_Stamp->AppendL(datum_und_uhrzeit);
//mac ID des benutzers speichern
TBuf<65> macidstring;
macidstring = pApp->DezimalMacIDtoString(MacID);
iItemArray_MacID->AppendL(macidstring); // mac id speichern
// Firma speichern
TBuf<65> firmastring;
firmastring = pApp->DeviceFirma(MacID);
iItemArray_Firma->AppendL(firmastring); // mac id speichern
}
}
// ----------------------------------------------------
// ----------------------------------------------------
void CBlueJackXContainer::StopScan()
{
if (STOP==false)
{
// Stoppt den timer
STOP = true;
iTimer->Cancel();
}else{
CEikonEnv::Static()->AlertWin(_L("Status:"),_L("start first"));
}
}
void CBlueJackXContainer::StartScan(TInt intervall)
{
if (STOP==true)
{
// Startet den Timer zum Scannen
// erste mal suchen
pApp->BuddysSuchen();
STOP = false;
TInt ErrechneteMS;
ErrechneteMS = intervall * 1000000; // intervall mal eine sekunde
iTimer->Start( ErrechneteMS, ErrechneteMS, TCallBack( Tick, this ) );
}else{
CEikonEnv::Static()->AlertWin(_L("Status:"),_L("alreadry running"));
}
}
// ------------------ TIMER -----------------------
// ----------------------------------------------------
TInt CBlueJackXContainer::Tick( TAny* aPtr )
{
TRAPD( err, ((CBlueJackXContainer*)aPtr)->DoTickL() );
return err;
}
void CBlueJackXContainer::DoTickL()
{
Zahl++;
TBuf16<8> str;
str.Num(Zahl);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -