2 Copyright 2004-2007, The AROS Development Team. All rights reserved.
6 #include <aros/debug.h>
8 #define MUIMASTER_YES_INLINE_STDARG
9 #define IFF_CHUNK_BUFFER_SIZE 1024
11 #include <exec/types.h>
12 #include <libraries/mui.h>
13 #include <zune/customclasses.h>
14 #include <proto/utility.h>
15 #include <proto/intuition.h>
16 #include <proto/muimaster.h>
17 #include <proto/dos.h>
18 #include <proto/alib.h>
19 #include <proto/iffparse.h>
20 #include <proto/aros.h>
21 #include <aros/arosbase.h>
22 #include <aros/inquire.h>
26 #include "wandererprefs.h"
27 #include "../../libs/muimaster/classes/iconlist_attributes.h"
28 #include "iconwindow_attributes.h"
33 #include <prefs/prefhdr.h>
34 #include <prefs/wanderer.h>
41 /*** Instance Data **********************************************************/
42 struct WandererPrefs_DATA
44 ULONG wpd_NavigationMethod
;
45 ULONG wpd_ToolbarEnabled
;
46 ULONG wpd_ShowNetwork
;
47 ULONG wpd_ShowUserFiles
;
48 ULONG wpd_ScreenTitleString
[IFF_CHUNK_BUFFER_SIZE
];
50 ULONG wpd_IconListMode
;
51 ULONG wpd_IconTextMode
;
52 ULONG wpd_IconTextMaxLen
;
55 ULONG wpd_MultiLineOnFocus
;
57 struct List wpd_ViewSettings
;
60 struct WandererPrefs_ViewSettingsNode
62 struct Node wpbn_Node
;
65 struct TagItem32
*wpbn_Options
;
66 Object
*wpbn_NotifyObject
;
69 /*** Macros *****************************************************************/
70 #define SETUP_INST_DATA struct WandererPrefs_DATA *data = INST_DATA(CLASS, self)
72 /*** Utility Functions ******************************************************/
73 BOOL
SetString(STRPTR
*dst
, STRPTR src
)
77 if ( (*dst
== NULL
) || (strcmp(src
, *dst
) != 0) )
79 STRPTR tmp
= StrDup(src
);
93 static unsigned char strtochar(STRPTR st
)
98 /******** code from workbench/c/Info.c *******************/
99 static void fmtlarge(UBYTE
*buf
, ULONG num
)
113 if (num
>= 1073741824)
115 array
.val
= num
>> 30;
116 d
= ((UQUAD
)num
* 10 + 536870912) / 1073741824;
119 ch
= strtochar((STRPTR
)_(MSG_MEM_G
));
121 else if (num
>= 1048576)
123 array
.val
= num
>> 20;
124 d
= ((UQUAD
)num
* 10 + 524288) / 1048576;
127 ch
= strtochar((STRPTR
)_(MSG_MEM_M
));
129 else if (num
>= 1024)
131 array
.val
= num
>> 10;
132 d
= (num
* 10 + 512) / 1024;
135 ch
= strtochar((STRPTR
)_(MSG_MEM_K
));
143 ch
= strtochar((STRPTR
)_(MSG_MEM_B
));
146 if (!array
.dec
&& (d
> array
.val
* 10))
151 RawDoFmt(array
.dec
? "%lu.%lu" : "%lu", &array
, NULL
, buf
);
152 while (*buf
) { buf
++; }
157 /* Case-insensitive FindName()
158 * code from workbench/c/Version.c
161 struct Node
*findname(struct List
*list
, CONST_STRPTR name
)
165 ForeachNode(list
, node
)
167 if (!Stricmp(node
->ln_Name
, (STRPTR
) name
))
176 /*ProcessUserScreenTitle(): pattern matching of user screentitle...;*/
177 STRPTR
ProcessUserScreenTitle(STRPTR screentitlestr
)
179 /*Work in progress :-)
182 D(bug("[Wanderer] ProcessUserScreenTitle(),EXTERN screentitlestr=%s\n", screentitlestr
));
184 if (screentitlestr
==NULL
)
186 D(bug("[Wanderer] ProcessUserScreenTitle(),EXTERN screentitle=NULL\n"));
187 return screentitlestr
;
190 int screentitleleng
= strlen(screentitlestr
);
192 if (screentitleleng
<1)
194 D(bug("[Wanderer] ProcessUserScreenTitle(),EXTERN screentitleleng=%d\n", screentitleleng
));
195 return screentitleleng
;
198 STATIC
char title
[256];
199 char temp
[256], buffer
[256];
202 strcpy(temp
,screentitlestr
);
206 for (i
=0; i
<screentitleleng
; i
++)
211 if (screentitleleng
>=3)
215 if (strncmp(temp
+i
,"%wv",3)==0)
217 struct Library
*MyLibrary
;
218 MyLibrary
= (struct Library
*) findname(&SysBase
->LibList
, "workbench.library");
220 sprintf(infostr
,"%ld",MyLibrary
->lib_Version
);
221 sprintf(infostr
+strlen(infostr
),".");
222 sprintf(infostr
+strlen(infostr
),"%ld",MyLibrary
->lib_Revision
);
226 if (strncmp(temp
+i
,"%ov",3)==0)
228 struct Library
*AROSBase
=OpenLibrary(AROSLIBNAME
, AROSLIBVERSION
);
232 ArosInquire(AI_ArosVersion
, (IPTR
) &ver
,
235 sprintf(infostr
,"%d", ver
);
236 CloseLibrary(AROSBase
);
242 if (strncmp(temp
+i
,"%os",3)==0)
244 struct Library
*AROSBase
=OpenLibrary(AROSLIBNAME
, AROSLIBVERSION
);
248 ArosInquire(AI_ArosReleaseMajor
, (IPTR
) &ver
,
249 AI_ArosReleaseMinor
,(IPTR
) &rev
,
252 sprintf(infostr
,"%ld", ver
);
253 sprintf(infostr
+strlen(infostr
),".");
254 sprintf(infostr
+strlen(infostr
),"%ld",rev
);
255 CloseLibrary(AROSBase
);
260 if (strncmp(temp
+i
,"%wb",3)==0)
262 struct Library
*AROSBase
=OpenLibrary(AROSLIBNAME
, AROSLIBVERSION
);
266 ArosInquire(AI_ArosReleaseMajor
, (IPTR
) &ver
,
267 AI_ArosReleaseMinor
,(IPTR
) &rev
,
270 sprintf(infostr
,"%d", WANDERERVERS
);
271 sprintf(infostr
+strlen(infostr
),".");
272 sprintf(infostr
+strlen(infostr
),"%d",WANDERERREV
);
273 CloseLibrary(AROSBase
);
279 if (strncmp(temp
+i
,"%pc",3)==0)
281 fmtlarge(infostr
,AvailMem(MEMF_CHIP
));
286 if (strncmp(temp
+i
,"%pf",3)==0)
288 fmtlarge(infostr
,AvailMem(MEMF_FAST
));
292 if (strncmp(temp
+i
,"%pt",3)==0)
294 fmtlarge(infostr
,AvailMem(MEMF_ANY
));
298 if (strncmp(temp
+i
,"%PC",3)==0)
300 fmtlarge(infostr
,AvailMem(MEMF_CHIP
|MEMF_TOTAL
));
305 if (strncmp(temp
+i
,"%PF",3)==0)
307 fmtlarge(infostr
,AvailMem(MEMF_FAST
|MEMF_TOTAL
));
311 if (strncmp(temp
+i
,"%PT",3)==0)
313 fmtlarge(infostr
,AvailMem(MEMF_ANY
|MEMF_TOTAL
));
323 sprintf(title
,temp
, infostr
);
326 strncpy(buffer
, title
, i
);
327 strcpy(&buffer
[i
],&temp
[(i
+3)-strlen(infostr
)]);
328 strcpy(temp
, buffer
);
330 screentitleleng
=screentitleleng
+strlen(infostr
);
342 switch (screentitleleng
)
362 /*** Methods ****************************************************************/
363 Object
*WandererPrefs__OM_NEW(Class
*CLASS
, Object
*self
, struct opSet
*message
)
365 self
= (Object
*) DoSuperMethodA(CLASS
, self
, (Msg
) message
);
367 D(bug("WandererPrefs::New()\n"));
373 D(bug("WandererPrefs::New - reloading\n"));
375 NewList(&data
->wpd_ViewSettings
);
376 DoMethod(self
, MUIM_WandererPrefs_Reload
);
382 IPTR
WandererPrefs__OM_DISPOSE(Class
*CLASS
, Object
*self
, Msg message
)
386 return DoSuperMethodA(CLASS
, self
, (Msg
)message
);
389 IPTR
WandererPrefs__OM_SET(Class
*CLASS
, Object
*self
, struct opSet
*message
)
392 const struct TagItem
*tstate
= message
->ops_AttrList
;
395 while ((tag
= NextTagItem(&tstate
)) != NULL
)
399 case MUIA_IconWindowExt_NetworkBrowser_Show
:
400 data
->wpd_ShowNetwork
= (LONG
)tag
->ti_Data
;
403 case MUIA_IconWindowExt_UserFiles_ShowFilesFolder
:
404 data
->wpd_ShowUserFiles
= (LONG
)tag
->ti_Data
;
407 case MUIA_IconWindowExt_ScreenTitle_String
:
408 strcpy(data
->wpd_ScreenTitleString
,tag
->ti_Data
);
409 //data->wpd_ScreenTitleString = (LONG)tag->ti_Data;
412 case MUIA_IconWindowExt_Toolbar_Enabled
:
413 data
->wpd_ToolbarEnabled
= (LONG
)tag
->ti_Data
;
416 case MUIA_IconWindowExt_Toolbar_NavigationMethod
:
417 data
->wpd_NavigationMethod
= (LONG
)tag
->ti_Data
;
420 /* The Following attributes will be moved to the ViewSettings Specific Chunks */
422 case MUIA_IconList_IconListMode
:
423 data
->wpd_IconListMode
= (LONG
)tag
->ti_Data
;
426 case MUIA_IconList_LabelText_Mode
:
427 data
->wpd_IconTextMode
= (ULONG
)tag
->ti_Data
;
430 case MUIA_IconList_LabelText_MaxLineLen
:
431 data
->wpd_IconTextMaxLen
= (ULONG
)tag
->ti_Data
;
434 case MUIA_IconList_LabelText_MultiLine
:
435 data
->wpd_MultiLine
= (ULONG
)tag
->ti_Data
;
438 case MUIA_IconList_LabelText_MultiLineOnFocus
:
439 data
->wpd_MultiLineOnFocus
= (ULONG
)tag
->ti_Data
;
444 return DoSuperMethodA(CLASS
, self
, (Msg
)message
);
447 IPTR
WandererPrefs__OM_GET(Class
*CLASS
, Object
*self
, struct opGet
*message
)
450 IPTR
*store
= message
->opg_Storage
;
454 switch (message
->opg_AttrID
)
456 case MUIA_IconWindowExt_NetworkBrowser_Show
:
457 *store
= (IPTR
)data
->wpd_ShowNetwork
;
460 case MUIA_IconWindowExt_UserFiles_ShowFilesFolder
:
461 *store
= (IPTR
)data
->wpd_ShowUserFiles
;
464 case MUIA_IconWindowExt_ScreenTitle_String
:
465 *store
= (IPTR
)data
->wpd_ScreenTitleString
;
466 D(bug("[WANDERER.PREFS] WandererPrefs__GET@@@@@@@@@: SCREENTITLE= %s\n", data
->wpd_ScreenTitleString
));
469 case MUIA_IconWindowExt_Toolbar_NavigationMethod
:
470 *store
= (IPTR
)data
->wpd_NavigationMethod
;
473 case MUIA_IconWindowExt_Toolbar_Enabled
:
474 *store
= (IPTR
)data
->wpd_ToolbarEnabled
;
477 case MUIA_IconList_IconListMode
:
478 *store
= (IPTR
)data
->wpd_IconListMode
;
481 case MUIA_IconList_LabelText_Mode
:
482 *store
= (IPTR
)data
->wpd_IconTextMode
;
485 case MUIA_IconList_LabelText_MaxLineLen
:
486 *store
= (IPTR
)data
->wpd_IconTextMaxLen
;
489 case MUIA_IconList_LabelText_MultiLine
:
490 *store
= (IPTR
)data
->wpd_MultiLine
;
493 case MUIA_IconList_LabelText_MultiLineOnFocus
:
494 *store
= (IPTR
)data
->wpd_MultiLineOnFocus
;
498 rv
= DoSuperMethodA(CLASS
, self
, (Msg
)message
);
504 BOOL
WandererPrefs_ProccessGlobalChunk(Class
*CLASS
, Object
*self
, struct TagItem32
*global_chunk
)
511 D(bug("[WANDERER.PREFS] WandererPrefs_ProccessGlobalChunk()\n"));
512 #warning "TODO: fix problems with endian-ness?"
514 for (i
=0; i
< WP_GLOBALTAGCOUNT
; i
++)
518 /* prefs file is stored in little endian */
519 if (AROS_LE2LONG(global_chunk
[i
].ti_Tag
) == TAG_DONE
) cont
= FALSE
;
520 else SET(self
, AROS_LE2LONG(global_chunk
[i
].ti_Tag
), AROS_LE2LONG(global_chunk
[i
].ti_Data
));
527 BOOL
WPEditor_ProccessNetworkChunk(Class
*CLASS
, Object
*self
, UBYTE
*_viewSettings_Chunk
)
531 struct TagItem
*network_tags
=(struct TagItem32
*) _viewSettings_Chunk
;
532 SET(self
, AROS_LE2LONG(network_tags
[0].ti_Tag
), AROS_LE2LONG(network_tags
[0].ti_Data
));
537 BOOL
WPEditor_ProccessScreenTitleChunk(Class
*CLASS
, Object
*self
, UBYTE
*_ScreenTitle_Chunk
)
542 D(bug("[WANDERER.PREFS] WandererPrefs__ProccessScreenTitleChunk@@@@@@@@@: SCREENTITLE to write= %s\n", _ScreenTitle_Chunk
));
544 char *userscreentitle
= ProcessUserScreenTitle(_ScreenTitle_Chunk
);
545 D(bug("[WANDERER.PREFS] WandererPrefs__ProccessScreenTitleChunk@@@@@@@@@: SCREENTITLE returned= %s\n", userscreentitle
));
547 if (userscreentitle
==NULL
)
548 SET(self
, MUIA_IconWindowExt_ScreenTitle_String
,_ScreenTitle_Chunk
);
550 SET(self
, MUIA_IconWindowExt_ScreenTitle_String
,userscreentitle
);
551 D(bug("[WANDERER.PREFS] WandererPrefs__ProccessScreenTitleChunk@@@@@@@@@: SCREENTITLE setted\n"));
556 struct WandererPrefs_ViewSettingsNode
*WandererPrefs_FindViewSettingsNode(struct WandererPrefs_DATA
*data
, char *node_Name
)
558 struct WandererPrefs_ViewSettingsNode
*current_Node
= NULL
;
560 ForeachNode(&data
->wpd_ViewSettings
, current_Node
)
562 if ((strcmp(current_Node
->wpbn_Name
, node_Name
)) == 0) return current_Node
;
567 BOOL
WandererPrefs_ProccessViewSettingsChunk(Class
*CLASS
, Object
*self
, char *_viewSettings_ViewName
, UBYTE
*_viewSettings_Chunk
, IPTR chunk_size
)
571 D(bug("[WANDERER.PREFS] WandererPrefs_ProccessViewSettingsChunk()\n"));
572 BOOL background_node_found
= FALSE
;
573 struct WandererPrefs_ViewSettingsNode
*_viewSettings_Node
= NULL
;
575 _viewSettings_Node
= WandererPrefs_FindViewSettingsNode(data
, _viewSettings_ViewName
);
577 if (_viewSettings_Node
)
579 D(bug("[WANDERER.PREFS] WandererPrefs_ProccessViewSettingsChunk: Updating Existing node @ %x\n", _viewSettings_Node
));
580 if (_viewSettings_Node
->wpbn_Background
) FreeVec(_viewSettings_Node
->wpbn_Background
);
584 D(bug("[WANDERER.PREFS] WandererPrefs_ProccessViewSettingsChunk: Creating new node for '%s'\n", _viewSettings_ViewName
));
585 _viewSettings_Node
= AllocMem(sizeof(struct WandererPrefs_ViewSettingsNode
), MEMF_CLEAR
|MEMF_PUBLIC
);
587 _viewSettings_Node
->wpbn_Name
= AllocVec(strlen(_viewSettings_ViewName
) + 1, MEMF_CLEAR
|MEMF_PUBLIC
);
588 strcpy(_viewSettings_Node
->wpbn_Name
, _viewSettings_ViewName
);
590 _viewSettings_Node
->wpbn_NotifyObject
= NotifyObject
, End
;
592 AddTail(&data
->wpd_ViewSettings
, &_viewSettings_Node
->wpbn_Node
);
595 _viewSettings_Node
->wpbn_Background
=(IPTR
) AllocVec(strlen(_viewSettings_Chunk
) + 1, MEMF_CLEAR
|MEMF_PUBLIC
);
596 strcpy((char *)_viewSettings_Node
->wpbn_Background
, _viewSettings_Chunk
);
597 D(bug("[WANDERER.PREFS] WandererPrefs_ProccessViewSettingsChunk: NAME BACKGROUND= %s\n",_viewSettings_Chunk
));
598 SET(_viewSettings_Node
->wpbn_NotifyObject
, MUIA_Background
, _viewSettings_Chunk
);
600 if (chunk_size
> (strlen(_viewSettings_Chunk
) + 1))
602 D(bug("[WANDERER.PREFS] WandererPrefs_ProccessViewSettingsChunk: Chunk has options Tag data ..\n"));
603 UBYTE _viewSettings_TagOffset
= ((strlen(_viewSettings_Chunk
) + 1)/4);
605 if ((_viewSettings_TagOffset
* 4) != (strlen(_viewSettings_Chunk
) + 1))
607 _viewSettings_TagOffset
= (_viewSettings_TagOffset
+ 1) * 4;
608 D(bug("[WPEditor] WPEditor_ProccessBackgroundChunk: String length unalined - rounding up (length %d, rounded %d) \n", strlen(_viewSettings_Chunk
) + 1, _viewSettings_TagOffset
));
612 _viewSettings_TagOffset
= _viewSettings_TagOffset
* 4;
613 D(bug("[WPEditor] WPEditor_ProccessBackgroundChunk: String length doesnt need aligned (length %d) \n", strlen(_viewSettings_Chunk
) + 1));
616 IPTR _viewSettings_TagCount
= ((chunk_size
- _viewSettings_TagOffset
)/sizeof(struct TagItem32
));
618 D(bug("[WANDERER.PREFS] WandererPrefs_ProccessViewSettingsChunk: %d Tags at offset %d ..\n", _viewSettings_TagCount
, _viewSettings_TagOffset
));
620 if (_viewSettings_Node
->wpbn_Options
!= NULL
)
622 D(bug("[WANDERER.PREFS] WandererPrefs_ProccessViewSettingsChunk: Freeing old background tag's @ %x\n", _viewSettings_Node
->wpbn_Options
));
623 FreeVec(_viewSettings_Node
->wpbn_Options
);
624 _viewSettings_Node
->wpbn_Options
= NULL
;
627 _viewSettings_Node
->wpbn_Options
= AllocVec((_viewSettings_TagCount
+ 1) * sizeof(struct TagItem32
), MEMF_CLEAR
|MEMF_PUBLIC
);
628 D(bug("[WANDERER.PREFS] WandererPrefs_ProccessViewSettingsChunk: New tag storage @ %x\n", _viewSettings_Node
->wpbn_Options
));
630 CopyMem(_viewSettings_Chunk
+ _viewSettings_TagOffset
, _viewSettings_Node
->wpbn_Options
, (_viewSettings_TagCount
) * sizeof(struct TagItem32
));
631 D(bug("[WANDERER.PREFS] WandererPrefs_ProccessViewSettingsChunk: Tags copied to storage \n"));
633 _viewSettings_Node
->wpbn_Options
[_viewSettings_TagCount
].ti_Tag
= TAG_DONE
;
636 for (i
= 0; i
< _viewSettings_TagCount
; i
++)
638 D(bug("[WANDERER.PREFS] WandererPrefs_ProccessViewSettingsChunk: Setting Tag %x Value %d\n", AROS_LE2LONG(_viewSettings_Node
->wpbn_Options
[i
].ti_Tag
), AROS_LE2LONG(_viewSettings_Node
->wpbn_Options
[i
].ti_Data
)));
639 SET(_viewSettings_Node
->wpbn_NotifyObject
, AROS_LE2LONG(_viewSettings_Node
->wpbn_Options
[i
].ti_Tag
), AROS_LE2LONG(_viewSettings_Node
->wpbn_Options
[i
].ti_Data
));
645 IPTR WandererPrefs__MUIM_WandererPrefs_Reload
647 Class
*CLASS
, Object
*self
, Msg message
650 struct ContextNode
*context
;
651 struct IFFHandle
*handle
;
654 IPTR iff_parse_mode
= IFFPARSE_SCAN
;
655 UBYTE chunk_buffer
[IFF_CHUNK_BUFFER_SIZE
];
657 D(bug("WandererPrefs::Reload\n"));
659 if (!(handle
= AllocIFF()))
662 handle
->iff_Stream
= (IPTR
) Open("ENV:SYS/Wanderer.prefs", MODE_OLDFILE
);
664 if (!handle
->iff_Stream
) return FALSE
;
666 InitIFFasDOS(handle
);
668 if ((error
= OpenIFF(handle
, IFFF_READ
)) == 0)
670 if ((error
= StopChunk(handle
, ID_PREF
, ID_WANDR
)) == 0)
672 SET(self
, MUIA_WandererPrefs_Processing
, TRUE
);
675 if ((error
= ParseIFF(handle
, iff_parse_mode
)) == 0)
677 context
= CurrentChunk(handle
);
678 iff_parse_mode
= IFFPARSE_STEP
;
680 D(bug("[WANDERER.PREFS] WandererPrefs__MUIM_WandererPrefs_Reload: Context %x\n", context
));
682 if ((error
=ReadChunkBytes(handle
, chunk_buffer
, IFF_CHUNK_BUFFER_SIZE
)))
684 D(bug("[WANDERER.PREFS] WandererPrefs__MUIM_WandererPrefs_Reload: ReadChunkBytes() Chunk matches Prefs Header size ..\n"));
685 struct WandererPrefsIFFChunkHeader
*this_header
=(struct WandererPrefsIFFChunkHeader
*) chunk_buffer
;
686 char *this_chunk_name
= NULL
;
687 IPTR this_chunk_size
= AROS_LE2LONG(this_header
->wpIFFch_ChunkSize
);
690 if ((this_chunk_name
= AllocVec(strlen(this_header
->wpIFFch_ChunkType
) +1,MEMF_ANY
|MEMF_CLEAR
)))
692 strcpy(this_chunk_name
, this_header
->wpIFFch_ChunkType
);
693 D(bug("[WANDERER.PREFS] WandererPrefs__MUIM_WandererPrefs_Reload: Prefs Header for '%s' data size %d bytes\n", this_chunk_name
, this_chunk_size
));
695 if ((error
= ParseIFF(handle
, IFFPARSE_STEP
)) == IFFERR_EOC
)
697 D(bug("[WANDERER.PREFS] WandererPrefs__MUIM_WandererPrefs_Reload: End of header chunk ..\n"));
699 if ((error
= ParseIFF(handle
, IFFPARSE_STEP
)) == 0)
701 context
= CurrentChunk(handle
);
703 D(bug("[WANDERER.PREFS] WandererPrefs__MUIM_WandererPrefs_Reload: Context %x\n", context
));
705 error
= ReadChunkBytes(
711 if (error
== this_chunk_size
)
713 D(bug("[WANDERER.PREFS] WandererPrefs__MUIM_WandererPrefs_Reload: ReadChunkBytes() Chunk matches Prefs Data size .. (%d)\n", error
));
714 if ((strcmp(this_chunk_name
, "wanderer:global")) == 0)
716 D(bug("[WANDERER.PREFS] WandererPrefs__MUIM_WandererPrefs_Reload: Process data for wanderer global chunk ..\n"));
717 WandererPrefs_ProccessGlobalChunk(CLASS
, self
,(struct TagItem32
*) chunk_buffer
);
719 else if ((strcmp(this_chunk_name
, "wanderer:network")) == 0)
721 D(bug("[WPEditor] WPEditor__MUIM_PrefsEditor_ImportFH: Process data for wanderer network config chunk ..\n"));
722 WPEditor_ProccessNetworkChunk(CLASS
, self
, chunk_buffer
);
724 else if ((strcmp(this_chunk_name
, "wanderer:screentitle")) == 0)
726 D(bug("[WPEditor] WPEditor__MUIM_PrefsEditor_ImportFH: Process data for wanderer screentitle config chunk ..size=%d\n", error
));
727 D(bug("[WPEditor] WPEditor__MUIM_PrefsEditor_ImportFH: Process data for wanderer screentitle STRING= %s\n", chunk_buffer
));
728 WPEditor_ProccessScreenTitleChunk(CLASS
, self
, chunk_buffer
);
731 else if ((strncmp(this_chunk_name
, "wanderer:viewsettings", strlen("wanderer:viewsettings"))) == 0)
733 char *view_name
= this_chunk_name
+ strlen("wanderer:viewsettings") + 1;
734 D(bug("[WANDERER.PREFS] WandererPrefs__MUIM_WandererPrefs_Reload: Process data for wanderer background chunk '%s'..\n", view_name
));
735 WandererPrefs_ProccessViewSettingsChunk(CLASS
, self
, view_name
, chunk_buffer
, this_chunk_size
);
737 }//END if (error == this_chunk_size)
738 if ((error
= ParseIFF(handle
, IFFPARSE_STEP
)) == IFFERR_EOC
)
740 D(bug("[WANDERER.PREFS] WandererPrefs__MUIM_WandererPrefs_Reload: End of Data chunk ..\n"));
742 }//END if ((error = ParseIFF(handle, IFFPARSE_STEP)) == 0)
743 }//END if ((error = ParseIFF(handle, IFFPARSE_STEP)) == IFFERR_EOC)
744 }//END if ((this_chunk_name = AllocVec(strlen(this_header->wpIFFch_ChunkType) +1,MEMF_ANY|MEMF_CLEAR)))
745 }//END if ((error=ReadChunkBytes(handle, chunk_buffer, IFF_CHUNK_BUFFER_SIZE)))
749 D(bug("[WANDERER.PREFS] ParseIFF() failed, returncode %ld!\n", error
));
751 }//END if ((error = ParseIFF(handle, iff_parse_mode)) == 0)
753 } while (error
!= IFFERR_EOF
);
754 SET(self
, MUIA_WandererPrefs_Processing
, FALSE
);
758 D(bug("[WANDERER.PREFS] StopChunk() failed, returncode %ld!\n", error
));
766 D(bug("[WANDERER.PREFS] Failed to open stream!, returncode %ld!\n", error
));
767 //ShowError(_(MSG_CANT_OPEN_STREAM));
769 }//END if ((error = StopChunk(handle, ID_PREF, ID_WANDR)) == 0)
771 Close((APTR
)handle
->iff_Stream
);
779 IPTR WandererPrefs__MUIM_WandererPrefs_ViewSettings_GetNotifyObject
781 Class
*CLASS
, Object
*self
, struct MUIP_WandererPrefs_ViewSettings_GetNotifyObject
*message
785 struct WandererPrefs_ViewSettingsNode
*current_Node
= NULL
;
787 D(bug("[WANDERER.PREFS] WandererPrefs__MUIM_WandererPrefs_ViewSettings_GetNotifyObject()\n"));
789 if ((current_Node
= WandererPrefs_FindViewSettingsNode(data
, message
->Background_Name
)))
791 D(bug("[WANDERER.PREFS] WandererPrefs__MUIM_WandererPrefs_ViewSettings_GetNotifyObject: Returning Object for existing record\n"));
792 return (IPTR
) current_Node
->wpbn_NotifyObject
;
795 current_Node
= AllocMem(sizeof(struct WandererPrefs_ViewSettingsNode
), MEMF_CLEAR
|MEMF_PUBLIC
);
796 D(bug("[WANDERER.PREFS] WandererPrefs__MUIM_WandererPrefs_ViewSettings_GetNotifyObject: Created new node ..\n"));
798 current_Node
->wpbn_Name
= AllocVec(strlen(message
->Background_Name
) + 1, MEMF_CLEAR
|MEMF_PUBLIC
);
799 strcpy(current_Node
->wpbn_Name
, message
->Background_Name
);
801 current_Node
->wpbn_NotifyObject
= NotifyObject
, End
;
803 AddTail(&data
->wpd_ViewSettings
, ¤t_Node
->wpbn_Node
);
805 D(bug("[WANDERER.PREFS] WandererPrefs__MUIM_WandererPrefs_ViewSettings_GetNotifyObject: Notify Object @ %x\n", current_Node
->wpbn_NotifyObject
));
807 return (IPTR
) current_Node
->wpbn_NotifyObject
;
810 #warning "TODO: Replace with propper 64bit check"
811 /* 32bit replacements for utility.library tag funcs */
812 struct TagItem32
* NextTag32Item(struct TagItem32
** tagListPtr
)
814 if(!(*tagListPtr
)) return NULL
;
818 switch ((*tagListPtr
)->ti_Tag
)
824 (*tagListPtr
) = NULL
;
828 (*tagListPtr
) += (*tagListPtr
)->ti_Data
+ 1;
832 /* Use post-increment (return will return the current value and
833 then tagListPtr will be incremented) */
834 return (struct TagItem32
*)(*tagListPtr
)++;
841 struct TagItem32
* FindTag32Item(ULONG tagValue
, struct TagItem32
*tagList
)
843 struct TagItem32
*tag
;
844 const struct TagItem32
*tagptr
= tagList
;
846 while( (tag
= NextTag32Item(&tagptr
)) )
848 if(tag
->ti_Tag
== tagValue
) return tag
;
855 IPTR
GetTag32Data(ULONG tagValue
, ULONG defaultVal
, struct TagItem32
*tagList
)
857 struct TagItem32
*ti
= NULL
;
859 if ((tagList
!= NULL
) && (ti
= FindTag32Item(tagValue
, tagList
)))
865 IPTR WandererPrefs__MUIM_WandererPrefs_ViewSettings_GetAttribute
867 Class
*CLASS
, Object
*self
, struct MUIP_WandererPrefs_ViewSettings_GetAttribute
*message
871 struct WandererPrefs_ViewSettingsNode
*current_Node
= NULL
;
873 D(bug("[WANDERER.PREFS] WandererPrefs__MUIM_WandererPrefs_ViewSettings_GetAttribute()\n"));
875 if ((current_Node
= WandererPrefs_FindViewSettingsNode(data
, message
->Background_Name
)))
877 D(bug("[WANDERER.PREFS] WandererPrefs__MUIM_WandererPrefs_ViewSettings_GetAttribute: Found Background Record ..\n"));
878 if (message
->AttributeID
== MUIA_Background
)
880 if (current_Node
->wpbn_Background
) return current_Node
->wpbn_Background
;
882 else if (current_Node
->wpbn_Options
)
884 if (sizeof(IPTR
) > 4)
886 D(bug("[WANDERER.PREFS] WandererPrefs__MUIM_WandererPrefs_ViewSettings_GetAttribute: Using internal GetTag32Data()\n"));
887 return GetTag32Data(message
->AttributeID
, (IPTR
)-1, current_Node
->wpbn_Options
);
891 D(bug("[WANDERER.PREFS] WandererPrefs__MUIM_WandererPrefs_ViewSettings_GetAttribute: Using utility.library->GetTagData()\n"));
892 return GetTagData(message
->AttributeID
, (IPTR
)-1, current_Node
->wpbn_Options
);
899 /*** Setup ******************************************************************/
902 WandererPrefs
, NULL
, MUIC_Notify
, NULL
,
903 OM_NEW
, struct opSet
*,
905 OM_SET
, struct opSet
*,
906 OM_GET
, struct opGet
*,
907 MUIM_WandererPrefs_Reload
, Msg
,
908 MUIM_WandererPrefs_ViewSettings_GetNotifyObject
, struct MUIP_WandererPrefs_ViewSettings_GetNotifyObject
*,
909 MUIM_WandererPrefs_ViewSettings_GetAttribute
, struct MUIP_WandererPrefs_ViewSettings_GetAttribute
*