×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Apr 2004
    Posts
    2

    Are there known issues with SDK 3 N6310i and Delphi?

    Hi!

    I am trying to use the PhoneBook component, and the TodoService, but it will just not work, also tried the CalendarItem, no success there...

    What could be wrong? The phone has connected successfully to the PC, it has been found by the connection manager...

    I am running xp pro with SP1...

    Does some of you also have a simple code for reading the first phonebook contact in delphi, and perhaps todoitem an calandaritem...

    I have tried in several ways and it will not work...

    Regards

    Martin Arvidsson, Consult M. Arvidsson, Sweden

  2. #2
    Registered User
    Join Date
    Mar 2004
    Posts
    18
    Hi.
    I have some experience of working with PhoneBook module, but not with Todo or Calendar modules

    So i try to help you to get started with PhoneBook.

    If you are using N6310i, you should work with IPhoneBook3 interface.

    Here is an sample of unit, that contains an implementation of IPhoneBook3 interface:

    ------------------------------------

    unit PhoneBook;

    interface

    uses PhonebookAdapterDS3_TLB, OleServer, Classes,
    ActiveX, Forms, PhoneBookTypes,
    NokiaCLSettings_TLB;

    type

    TPhoneBook3 = class(TObject)
    private
    FIntf: IPhonebook3;

    public
    constructor Create;
    destructor Destroy;

    class procedure GetPhoneBook;

    function GetLogMemory(physMemory: PhysicalMem): LogicalMem;
    function GetContact(SearchMode: SearchMode; SearchKey: SearchKey; PhysicalMemory: PhysicalMem;
    LogicalMemory: LogicalMem; var Location: Integer;
    const searchString: WideString; out ppContact: IContact2): HResult; overload;
    function CreateContact(out ppContact: IContact2): HResult;
    function SetContact(var Location: Integer; const pContact: IContact2): HResult;
    function DeleteContact(PhysicalMemory: PhysicalMem; LogicalMemory: LogicalMem; Location: Integer): HResult;
    function GetCallerGroup(group: Integer; out ppCallerGroup: ICallerGroup2): HResult;
    function GetMemoryCaps(PhysicalMemory: PhysicalMem; LogicalMemory: LogicalMem;
    var pMaxAmount: Integer; var pFull: Integer; var pFractation: Integer): HResult; overload;
    procedure SetMemoryInUse(PhysicalMemory: PhysicalMem);
    function GetLastError: NmpAdapterError;

    class function GetInstance: TPhoneBook3;

    end;


    implementation

    uses SysUtils, ComObj;


    {$J+}
    class function TPhoneBook3.GetInstance: TPhoneBook3;
    const
    instance: TPhoneBook3 = nil;
    begin
    if not Assigned(instance) then
    instance:= TPhoneBook3.Create;
    Result:= instance;
    end;
    {$J-}


    function TPhoneBook3.GetLogMemory(physMemory: PhysicalMem): LogicalMem;
    begin
    Result:= LOG_MEM_DEFAULT;
    case physMemory of
    PHYS_MEM_SIM: Result:= LOG_MEM_ADN;
    PHYS_MEM_PHONE: Result:= LOG_MEM_PD;
    end;
    end;


    procedure TPhoneBook3.SetMemoryInUse(PhysicalMemory: PhysicalMem);
    begin
    FIntf.SetMemoryInUse(PhysicalMemory);
    end;

    function TPhoneBook3.GetMemoryCaps(PhysicalMemory: PhysicalMem; LogicalMemory: LogicalMem;
    var pMaxAmount: Integer; var pFull: Integer; var pFractation: Integer): HResult;
    begin
    Result := FIntf.GetMemoryCaps(PhysicalMemory, LogicalMemory, pMaxAmount, pFull, pFractation);
    end;

    function TPhoneBook3.GetContact(SearchMode: SearchMode; SearchKey: SearchKey; PhysicalMemory: PhysicalMem;
    LogicalMemory: LogicalMem; var Location: Integer;
    const searchString: WideString; out ppContact: IContact2): HResult;
    begin
    Result := FIntf.GetContact(SearchMode, SearchKey, PhysicalMemory, LogicalMemory, Location,
    searchString, ppContact);
    end;
    function TPhoneBook3.CreateContact(out ppContact: IContact2): HResult;
    begin
    Result := FIntf.CreateContact(ppContact);
    end;

    function TPhoneBook3.SetContact(var Location: Integer; const pContact: IContact2): HResult;
    begin
    Result := FIntf.SetContact(Location, pContact);
    end;

    function TPhoneBook3.DeleteContact(PhysicalMemory: PhysicalMem; LogicalMemory: LogicalMem; Location: Integer): HResult;
    begin
    Result := FIntf.DeleteContact(PhysicalMemory, LogicalMemory, Location);
    end;

    function TPhoneBook3.GetCallerGroup(group: Integer; out ppCallerGroup: ICallerGroup2): HResult;
    begin
    Result := FIntf.GetCallerGroup(group, ppCallerGroup);
    end;

    function TPhoneBook3.GetLastError: NmpAdapterError;
    var
    pErr: NmpAdapterError;
    begin
    FIntf.GetLastError(pErr);
    Result := pErr;
    end;

    class procedure TPhoneBook3.GetPhoneBook;
    var

    i, pMaxAmount, pFull, pGrpMaxAmount, pGrpFull, pSIMMaxAmount,
    pFractation, pSIMFull, pPhoneMaxAmount, pPhoneFull: integer;

    contact: IContact2;
    location: longint;

    cliColl: ICLIColl;
    cliItem: ICLIItem;

    begin

    with Fint do begin


    try

    cliColl:= CoCLIColl.Create;
    cliColl.Enumerate;
    pGrpFull:= cliColl.Count;

    OleCheck(GetMemoryCaps(PHYS_MEM_SIM, LOG_MEM_ADN, pSIMMaxAmount, pSIMFull, pFractation));

    OleCheck(GetMemoryCaps(PHYS_MEM_PHONE, LOG_MEM_PD, pPhoneMaxAmount, pPhoneFull, pFractation));

    OleCheck(GetMemoryCaps(PHYS_MEM_SIM, LOG_MEM_SDN, pMaxAmount, pFull, pFractation));


    // Read service numbers
    location:=0;
    OleCheck(GetContact(MODE_FIRST, KEY_LOCATION, PHYS_MEM_SIM, LOG_MEM_SDN, location, '' ,contact));
    if contact<>nil then //!!! method for store contact information
    for i:=1 to pFull-1 do begin
    OleCheck(GetContact(MODE_NEXT, KEY_LOCATION, PHYS_MEM_SIM, LOG_MEM_SDN, location, '' ,contact));
    if contact<>nil then //!!! method for store contact information
    end;

    // Read groups
    for i:= 1 to pGrpFull do begin
    cliItem:= cliColl.Item[i];
    cliItem.Get_Index(groupId);
    cliItem.Get_Name(groupName);
    if groupName = '' then cliItem.Get_DefaultName(groupName);

    //!!! method for store group information

    end;
    cliColl:= nil;

    // Read SIM memory
    location:=0;
    OleCheck(GetContact(MODE_FIRST, KEY_LOCATION, PHYS_MEM_SIM, LOG_MEM_ADN, location, '' ,contact));
    if contact<>nil then //!!! method for store contact information
    for i:=1 to pSIMFull-1 do begin
    OleCheck(GetContact(MODE_NEXT, KEY_LOCATION, PHYS_MEM_SIM, LOG_MEM_ADN, location, '' ,contact));
    if contact<>nil then //!!! method for store contact information
    end;

    // Read PHONE memory
    location:=0;
    OleCheck(GetContact(MODE_FIRST, KEY_LOCATION, PHYS_MEM_PHONE, LOG_MEM_PD, location, '' ,contact));
    if contact<>nil then //!!! method for store contact information
    for i:=1 to pPhoneFull-1 do begin
    OleCheck(GetContact(MODE_NEXT, KEY_LOCATION, PHYS_MEM_PHONE, LOG_MEM_PD, location, '' ,contact));
    if contact<>nil then //!!! method for store contact information
    end;


    except
    on EOleSysError do //... exception process procedure
    end;

    end;
    end;


    constructor TPhoneBook3.Create;
    begin
    inherited;
    FIntf:= CreateComObject(CLASS_PhonebookSuite3) as IPhonebook3;
    end;

    destructor TPhoneBook3.Destroy;
    begin
    FIntf:= nil;
    inherited;
    end;

    end.

    ------------------------------------

    I hope this help you to understand how the PhoneBook works.

    Best regards,
    Alexey K.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×