From 8959a4e0c37873f56f44ea1743902de0ec0e44d4 Mon Sep 17 00:00:00 2001 From: Andreas Henriksson Date: Thu, 19 Jul 2012 23:37:42 +0200 Subject: [PATCH 01/46] An unused dirty block would put again into the unused list. * This could cause bug #8123. While this fixes the crash, one underlying problem is still there, as dirty blocks should never leave a transaction. --- src/system/kernel/cache/block_cache.cpp | 4 +++- src/tools/fs_shell/block_cache.cpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/system/kernel/cache/block_cache.cpp b/src/system/kernel/cache/block_cache.cpp index b49bf6e902..e0c258b804 100644 --- a/src/system/kernel/cache/block_cache.cpp +++ b/src/system/kernel/cache/block_cache.cpp @@ -1268,7 +1268,7 @@ BlockWriter::_BlockDone(cached_block* block, hash_iterator* iterator) fDeletedTransaction = true; } } - if (block->transaction == NULL && block->ref_count == 0) { + if (block->transaction == NULL && block->ref_count == 0 && !block->unused) { // the block is no longer used block->unused = true; fCache->unused_blocks.Add(block); @@ -1761,7 +1761,9 @@ put_cached_block(block_cache* cache, cached_block* block) cache->RemoveBlock(block); } else { // put this block in the list of unused blocks + ASSERT(!block->unused); block->unused = true; + ASSERT(block->original_data == NULL && block->parent_data == NULL); cache->unused_blocks.Add(block); diff --git a/src/tools/fs_shell/block_cache.cpp b/src/tools/fs_shell/block_cache.cpp index 78f69d2865..2f47a094dc 100644 --- a/src/tools/fs_shell/block_cache.cpp +++ b/src/tools/fs_shell/block_cache.cpp @@ -927,7 +927,7 @@ write_cached_block(block_cache* cache, cached_block* block, } } } - if (block->transaction == NULL && block->ref_count == 0) { + if (block->transaction == NULL && block->ref_count == 0 && !block->unused) { // the block is no longer used block->unused = true; cache->unused_blocks.Add(block); From 9be0c9b03c9e25270699d59a363355cea083f63b Mon Sep 17 00:00:00 2001 From: Philippe Houdoin Date: Thu, 19 Jul 2012 23:24:52 +0200 Subject: [PATCH 02/46] Improve SVG image identification (close #8653) * add a sniff rule * until we have an image translator for SVG, and since Web+ is not included by default in Haiku images, made Web+ preferred app for SVG images. Note that for compressed SVGZ (*.svgz), the sniff rule will still fail miserably. Our sniffer will need decompression support before being able to do that... --- src/data/beos_mime/image/svg+xml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/data/beos_mime/image/svg+xml b/src/data/beos_mime/image/svg+xml index 88ef6db6c1..94532c1cfa 100644 --- a/src/data/beos_mime/image/svg+xml +++ b/src/data/beos_mime/image/svg+xml @@ -5,8 +5,15 @@ resource(1, "META:TYPE") "image/svg+xml"; resource(2, "META:S:DESC") #'MSDC' "SVG image"; -resource(3, "META:EXTENS") message(234) { +resource(3, "META:SNIFF_RULE") #'CSTR' array { + "0.60 [0:511] ( -i \" Date: Thu, 19 Jul 2012 23:55:18 +0200 Subject: [PATCH 03/46] Added a bit of documentation, minor cleanup. * Documented the cached_block::transaction, and previous_transaction members. --- src/system/kernel/cache/block_cache.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/system/kernel/cache/block_cache.cpp b/src/system/kernel/cache/block_cache.cpp index e0c258b804..cc5b663531 100644 --- a/src/system/kernel/cache/block_cache.cpp +++ b/src/system/kernel/cache/block_cache.cpp @@ -89,7 +89,17 @@ struct cached_block { bool busy_reading_waiters : 1; bool busy_writing_waiters : 1; cache_transaction* transaction; + // This is the current active transaction, if any, the block is + // currently in (meaning was changed as a part of it). cache_transaction* previous_transaction; + // This is set to the last transaction that was ended containing this + // block. In this case, the block has not yet written back yet, and + // the changed data is either in current_data, or original_data -- the + // latter if the block is already being part of another transaction. + // There can only be one previous transaction, so when the active + // transaction ends, the changes of the previous transaction have to + // be written back before that transaction becomes the next previous + // transaction. bool CanBeWritten() const; int32 LastAccess() const @@ -1189,7 +1199,7 @@ BlockWriter::WriteBlock(block_cache* cache, cached_block* block) void* BlockWriter::_Data(cached_block* block) const { - return block->previous_transaction && block->original_data + return block->previous_transaction != NULL && block->original_data != NULL ? block->original_data : block->current_data; // We first need to write back changes from previous transactions } From 752f5c972f1a874cc7f93787e1a3bce6396c891e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 19 Jul 2012 23:57:10 +0200 Subject: [PATCH 04/46] cache_abort_[sub_]transaction() did not work correctly. * cache_abort_transaction() left the block dirty which was causing bug #8123 as well. * cache_abort_sub_transaction() did, in addition to not clearing the dirty flag, not reset the block's transaction member either if the block was not part of the parent transaction. --- src/system/kernel/cache/block_cache.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/system/kernel/cache/block_cache.cpp b/src/system/kernel/cache/block_cache.cpp index cc5b663531..943e6517f0 100644 --- a/src/system/kernel/cache/block_cache.cpp +++ b/src/system/kernel/cache/block_cache.cpp @@ -2877,6 +2877,8 @@ cache_abort_transaction(void* _cache, int32 id) block->transaction_next = NULL; block->transaction = NULL; block->discard = false; + if (block->previous_transaction == NULL) + block->is_dirty = false; } hash_remove(cache->transaction_hash, transaction); @@ -3028,17 +3030,24 @@ cache_abort_sub_transaction(void* _cache, int32 id) next = block->transaction_next; if (block->parent_data == NULL) { - // the parent transaction didn't change the block, but the sub - // transaction did - we need to revert from the original data + // The parent transaction didn't change the block, but the sub + // transaction did - we need to revert to the original data. + // The block is no longer part of the transaction ASSERT(block->original_data != NULL); memcpy(block->current_data, block->original_data, cache->block_size); + block->transaction_next = NULL; + block->transaction = NULL; + if (block->previous_transaction == NULL) + block->is_dirty = false; } else if (block->parent_data != block->current_data) { - // the block has been changed and must be restored + // The block has been changed and must be restored - the block + // is still dirty and part of the transaction TRACE(("cache_abort_sub_transaction(id = %ld): restored contents " "of block %Ld\n", transaction->id, block->block_number)); memcpy(block->current_data, block->parent_data, cache->block_size); cache->Free(block->parent_data); + // The block stays dirty } block->parent_data = NULL; From 173f54f1473bd6a6511c5fc6dc899c91fb8dd667 Mon Sep 17 00:00:00 2001 From: Matt Madia Date: Thu, 19 Jul 2012 18:11:40 +0000 Subject: [PATCH 05/46] Updated copyright in headers. No functional change. --- headers/posix/alloca.h | 2 +- headers/posix/arch/arm/arch_setjmp.h | 2 +- headers/posix/arch/arm/signal.h | 4 ++-- headers/posix/arch/m68k/arch_setjmp.h | 2 +- headers/posix/arch/m68k/signal.h | 4 ++-- headers/posix/arch/mipsel/arch_setjmp.h | 2 +- headers/posix/arch/mipsel/signal.h | 4 ++-- headers/posix/arch/ppc/arch_setjmp.h | 2 +- headers/posix/arch/ppc/signal.h | 4 ++-- headers/posix/arch/x86/arch_setjmp.h | 2 +- headers/posix/arch/x86/signal.h | 2 +- headers/posix/arch/x86_64/arch_setjmp.h | 2 +- headers/posix/arch/x86_64/signal.h | 4 ++-- headers/posix/arpa/inet.h | 2 +- headers/posix/arpa/nameser.h | 2 +- headers/posix/assert.h | 2 +- headers/posix/bsd_mem.h | 2 +- headers/posix/compat/sys/stat.h | 2 +- headers/posix/ctype.h | 2 +- headers/posix/dirent.h | 2 +- headers/posix/div_t.h | 2 +- headers/posix/dlfcn.h | 2 +- headers/posix/endian.h | 2 +- headers/posix/errno.h | 6 +++--- headers/posix/fcntl.h | 2 +- headers/posix/getopt.h | 2 +- headers/posix/grp.h | 2 +- headers/posix/inttypes.h | 2 +- headers/posix/iovec.h | 2 +- headers/posix/langinfo.h | 2 +- headers/posix/libgen.h | 2 +- headers/posix/limits.h | 2 +- headers/posix/locale.h | 2 +- headers/posix/malloc.h | 4 ++-- headers/posix/malloc_debug.h | 2 +- headers/posix/math.h | 2 +- headers/posix/memory.h | 6 +++--- headers/posix/monetary.h | 2 +- headers/posix/net/if.h | 2 +- headers/posix/net/if_dl.h | 2 +- headers/posix/net/if_media.h | 2 +- headers/posix/net/if_types.h | 2 +- headers/posix/net/route.h | 2 +- headers/posix/netdb.h | 2 +- headers/posix/netinet/in.h | 2 +- headers/posix/netinet/tcp.h | 4 ++-- headers/posix/netinet6/in6.h | 2 +- headers/posix/nl_types.h | 2 +- headers/posix/null.h | 2 +- headers/posix/poll.h | 2 +- headers/posix/pwd.h | 2 +- headers/posix/resolv.h | 2 +- headers/posix/sched.h | 2 +- headers/posix/search.h | 8 ++++---- headers/posix/semaphore.h | 2 +- headers/posix/setjmp.h | 2 +- headers/posix/shadow.h | 2 +- headers/posix/size_t.h | 2 +- headers/posix/stdint.h | 2 +- headers/posix/stdio.h | 2 +- headers/posix/stdio_ext.h | 2 +- headers/posix/stdio_post.h | 2 +- headers/posix/stdio_pre.h | 2 +- headers/posix/stdlib.h | 2 +- headers/posix/string.h | 2 +- headers/posix/sys/file.h | 2 +- headers/posix/sys/ioctl.h | 2 +- headers/posix/sys/ipc.h | 2 +- headers/posix/sys/mman.h | 2 +- headers/posix/sys/msg.h | 2 +- headers/posix/sys/param.h | 2 +- headers/posix/sys/poll.h | 2 +- headers/posix/sys/resource.h | 2 +- headers/posix/sys/select.h | 2 +- headers/posix/sys/sem.h | 2 +- headers/posix/sys/socket.h | 6 +++--- headers/posix/sys/sockio.h | 6 +++--- headers/posix/sys/stat.h | 2 +- headers/posix/sys/statvfs.h | 2 +- headers/posix/sys/time.h | 2 +- headers/posix/sys/timeb.h | 2 +- headers/posix/sys/times.h | 4 ++-- headers/posix/sys/types.h | 2 +- headers/posix/sys/uio.h | 2 +- headers/posix/sys/un.h | 4 ++-- headers/posix/sys/utsname.h | 2 +- headers/posix/syslog.h | 2 +- headers/posix/termios.h | 2 +- headers/posix/utime.h | 2 +- headers/posix/wchar.h | 2 +- headers/posix/wchar_t.h | 2 +- headers/posix/wctype.h | 2 +- 92 files changed, 112 insertions(+), 112 deletions(-) diff --git a/headers/posix/alloca.h b/headers/posix/alloca.h index 82bc2971c0..dfe8f0d180 100644 --- a/headers/posix/alloca.h +++ b/headers/posix/alloca.h @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010 Haiku Inc. All Rights Reserved. + * Copyright 2003-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _ALLOCA_H diff --git a/headers/posix/arch/arm/arch_setjmp.h b/headers/posix/arch/arm/arch_setjmp.h index 7db0bea9fe..d1f1a14a10 100644 --- a/headers/posix/arch/arm/arch_setjmp.h +++ b/headers/posix/arch/arm/arch_setjmp.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _ARCH_SETJMP_H_ diff --git a/headers/posix/arch/arm/signal.h b/headers/posix/arch/arm/signal.h index a6572ab074..19a593d5db 100644 --- a/headers/posix/arch/arm/signal.h +++ b/headers/posix/arch/arm/signal.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _ARCH_SIGNAL_H_ @@ -32,7 +32,7 @@ struct vregs ulong cpsr; #warning ARM: fix floats in vregs, add missing stuff. }; -#endif /* __ARM__ */ +#endif /* __ARM__ */ #endif /* _ARCH_SIGNAL_H_ */ diff --git a/headers/posix/arch/m68k/arch_setjmp.h b/headers/posix/arch/m68k/arch_setjmp.h index 6bf077a3f3..4aa8146a7f 100644 --- a/headers/posix/arch/m68k/arch_setjmp.h +++ b/headers/posix/arch/m68k/arch_setjmp.h @@ -1,5 +1,5 @@ /* - * Copyright 2007-2010 Haiku Inc. All Rights Reserved. + * Copyright 2007-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _ARCH_SETJMP_H_ diff --git a/headers/posix/arch/m68k/signal.h b/headers/posix/arch/m68k/signal.h index 8ff2f3e23a..6623e7a09d 100644 --- a/headers/posix/arch/m68k/signal.h +++ b/headers/posix/arch/m68k/signal.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _ARCH_SIGNAL_H_ @@ -21,7 +21,7 @@ struct vregs double f0, /* fp scratch */ f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13; /* fp volatile regs */ }; -#endif /* __M68K__ */ +#endif /* __M68K__ */ #endif /* _ARCH_SIGNAL_H_ */ diff --git a/headers/posix/arch/mipsel/arch_setjmp.h b/headers/posix/arch/mipsel/arch_setjmp.h index 8c7189cddc..66e147e37e 100644 --- a/headers/posix/arch/mipsel/arch_setjmp.h +++ b/headers/posix/arch/mipsel/arch_setjmp.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _ARCH_SETJMP_H_ diff --git a/headers/posix/arch/mipsel/signal.h b/headers/posix/arch/mipsel/signal.h index 37dfb97261..a3e1f22318 100644 --- a/headers/posix/arch/mipsel/signal.h +++ b/headers/posix/arch/mipsel/signal.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _ARCH_SIGNAL_H_ @@ -18,7 +18,7 @@ struct vregs #warning MIPSEL: fixme }; -#endif /* __MIPSEL__ */ +#endif /* __MIPSEL__ */ #endif /* _ARCH_SIGNAL_H_ */ diff --git a/headers/posix/arch/ppc/arch_setjmp.h b/headers/posix/arch/ppc/arch_setjmp.h index 93d552b1f4..f4e9cf16e5 100644 --- a/headers/posix/arch/ppc/arch_setjmp.h +++ b/headers/posix/arch/ppc/arch_setjmp.h @@ -1,5 +1,5 @@ /* - * Copyright 2005-2010 Haiku Inc. All Rights Reserved. + * Copyright 2005-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _ARCH_SETJMP_H_ diff --git a/headers/posix/arch/ppc/signal.h b/headers/posix/arch/ppc/signal.h index bdb67ce940..c1ef3f58d7 100644 --- a/headers/posix/arch/ppc/signal.h +++ b/headers/posix/arch/ppc/signal.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _ARCH_SIGNAL_H_ @@ -27,7 +27,7 @@ struct vregs fpscr, /* fp condition codes */ ctr, xer, cr, msr, lr; /* misc. status */ }; -#endif /* __POWERPC__ */ +#endif /* __POWERPC__ */ #endif /* _ARCH_SIGNAL_H_ */ diff --git a/headers/posix/arch/x86/arch_setjmp.h b/headers/posix/arch/x86/arch_setjmp.h index 5221087a78..f5d944f4b3 100644 --- a/headers/posix/arch/x86/arch_setjmp.h +++ b/headers/posix/arch/x86/arch_setjmp.h @@ -1,5 +1,5 @@ /* - * Copyright 2005-2010 Haiku Inc. All Rights Reserved. + * Copyright 2005-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _ARCH_SETJMP_H_ diff --git a/headers/posix/arch/x86/signal.h b/headers/posix/arch/x86/signal.h index 6d04281499..be3e743055 100644 --- a/headers/posix/arch/x86/signal.h +++ b/headers/posix/arch/x86/signal.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _ARCH_SIGNAL_H_ diff --git a/headers/posix/arch/x86_64/arch_setjmp.h b/headers/posix/arch/x86_64/arch_setjmp.h index 3780e9bb78..8371471f01 100644 --- a/headers/posix/arch/x86_64/arch_setjmp.h +++ b/headers/posix/arch/x86_64/arch_setjmp.h @@ -1,5 +1,5 @@ /* - * Copyright 2005-2010 Haiku Inc. All Rights Reserved. + * Copyright 2005-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _ARCH_SETJMP_H_ diff --git a/headers/posix/arch/x86_64/signal.h b/headers/posix/arch/x86_64/signal.h index bc97f98c6e..f48a72f5fa 100644 --- a/headers/posix/arch/x86_64/signal.h +++ b/headers/posix/arch/x86_64/signal.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _ARCH_SIGNAL_H_ @@ -40,7 +40,7 @@ struct vregs { */ }; - + #endif /* __x86_64__ */ #endif /* _ARCH_SIGNAL_H_ */ diff --git a/headers/posix/arpa/inet.h b/headers/posix/arpa/inet.h index 1c3c19168b..95ee6e3a91 100644 --- a/headers/posix/arpa/inet.h +++ b/headers/posix/arpa/inet.h @@ -1,5 +1,5 @@ /* - * Copyright 2009-2010 Haiku Inc. All Rights Reserved. + * Copyright 2009-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _INET_H_ diff --git a/headers/posix/arpa/nameser.h b/headers/posix/arpa/nameser.h index f62cdc496c..ae88a7a9aa 100644 --- a/headers/posix/arpa/nameser.h +++ b/headers/posix/arpa/nameser.h @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010 Haiku Inc. All Rights Reserved. + * Copyright 2006-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ diff --git a/headers/posix/assert.h b/headers/posix/assert.h index 1d47bd0ad6..b8668925d9 100644 --- a/headers/posix/assert.h +++ b/headers/posix/assert.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2010 Haiku Inc. All Rights Reserved. + * Copyright 2004-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _ASSERT_H_ diff --git a/headers/posix/bsd_mem.h b/headers/posix/bsd_mem.h index 0d2182aac5..a0e773cbee 100644 --- a/headers/posix/bsd_mem.h +++ b/headers/posix/bsd_mem.h @@ -1,5 +1,5 @@ /* - * Copyright 2005-2010 Haiku Inc. All Rights Reserved. + * Copyright 2005-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ diff --git a/headers/posix/compat/sys/stat.h b/headers/posix/compat/sys/stat.h index 9722e118c3..94aeca1933 100644 --- a/headers/posix/compat/sys/stat.h +++ b/headers/posix/compat/sys/stat.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _COMPAT_SYS_STAT_H_ diff --git a/headers/posix/ctype.h b/headers/posix/ctype.h index 9d75cea58c..57b2820eff 100644 --- a/headers/posix/ctype.h +++ b/headers/posix/ctype.h @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010 Haiku Inc. All Rights Reserved. + * Copyright 2003-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _CTYPE_H diff --git a/headers/posix/dirent.h b/headers/posix/dirent.h index ea8d941be8..9622a265ac 100644 --- a/headers/posix/dirent.h +++ b/headers/posix/dirent.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _DIRENT_H diff --git a/headers/posix/div_t.h b/headers/posix/div_t.h index 990240b93c..94b783225a 100644 --- a/headers/posix/div_t.h +++ b/headers/posix/div_t.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _DIV_T_H_ diff --git a/headers/posix/dlfcn.h b/headers/posix/dlfcn.h index 2b0a63fe09..7fdce4fc64 100644 --- a/headers/posix/dlfcn.h +++ b/headers/posix/dlfcn.h @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010 Haiku Inc. All Rights Reserved. + * Copyright 2003-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _DLFCN_H diff --git a/headers/posix/endian.h b/headers/posix/endian.h index a02cf9efe9..ba93bb128a 100644 --- a/headers/posix/endian.h +++ b/headers/posix/endian.h @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010 Haiku Inc. All rights reserved. + * Copyright 2003-2012 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _ENDIAN_H_ diff --git a/headers/posix/errno.h b/headers/posix/errno.h index e124f0ea89..045b24ec74 100644 --- a/headers/posix/errno.h +++ b/headers/posix/errno.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _POSIX_ERRNO_H @@ -9,7 +9,7 @@ #ifdef __cplusplus extern "C" { -#endif +#endif #include @@ -21,6 +21,6 @@ extern int *_errnop(void); #ifdef __cplusplus } /* "C" */ -#endif +#endif #endif /* _POSIX_ERRNO_H */ diff --git a/headers/posix/fcntl.h b/headers/posix/fcntl.h index a5561b3cd9..ad762f5b0d 100644 --- a/headers/posix/fcntl.h +++ b/headers/posix/fcntl.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _FCNTL_H diff --git a/headers/posix/getopt.h b/headers/posix/getopt.h index c39556bdd0..49694a6c1b 100644 --- a/headers/posix/getopt.h +++ b/headers/posix/getopt.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2010 Haiku Inc. All Rights Reserved. + * Copyright 2004-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _GETOPT_H diff --git a/headers/posix/grp.h b/headers/posix/grp.h index 7be9cca96f..e44c15c9f6 100644 --- a/headers/posix/grp.h +++ b/headers/posix/grp.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2010 Haiku Inc. All Rights Reserved. + * Copyright 2004-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _GRP_H_ diff --git a/headers/posix/inttypes.h b/headers/posix/inttypes.h index 5f24eda435..8abc015b68 100644 --- a/headers/posix/inttypes.h +++ b/headers/posix/inttypes.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All rights reserved. + * Copyright 2002-2012 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _INTTYPES_H_ diff --git a/headers/posix/iovec.h b/headers/posix/iovec.h index ec10f21acd..be253e3f01 100644 --- a/headers/posix/iovec.h +++ b/headers/posix/iovec.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _IOVEC_H diff --git a/headers/posix/langinfo.h b/headers/posix/langinfo.h index 1ee23de3da..cbd63bd8b2 100644 --- a/headers/posix/langinfo.h +++ b/headers/posix/langinfo.h @@ -1,5 +1,5 @@ /* - * Copyright 2010 Haiku Inc. All Rights Reserved. + * Copyright 2010-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _LANGINFO_H_ diff --git a/headers/posix/libgen.h b/headers/posix/libgen.h index a89bf98678..3cff2618f7 100644 --- a/headers/posix/libgen.h +++ b/headers/posix/libgen.h @@ -1,5 +1,5 @@ /* - * Copyright 2009-2010 Haiku Inc. All Rights Reserved. + * Copyright 2009-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _LIBGEN_H diff --git a/headers/posix/limits.h b/headers/posix/limits.h index 5f90d74059..e010cf3ea2 100644 --- a/headers/posix/limits.h +++ b/headers/posix/limits.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2012 Haiku Inc. All rights reserved. + * Copyright 2001-2012 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _LIBC_LIMITS_H_ diff --git a/headers/posix/locale.h b/headers/posix/locale.h index 624c717844..2cc8717623 100644 --- a/headers/posix/locale.h +++ b/headers/posix/locale.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _LOCALE_H_ diff --git a/headers/posix/malloc.h b/headers/posix/malloc.h index c5cc068e95..b36b17d9e9 100644 --- a/headers/posix/malloc.h +++ b/headers/posix/malloc.h @@ -1,12 +1,12 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _MALLOC_H #define _MALLOC_H -#include +#include #ifdef __cplusplus diff --git a/headers/posix/malloc_debug.h b/headers/posix/malloc_debug.h index 1bfe75a809..0c23bbb9e7 100644 --- a/headers/posix/malloc_debug.h +++ b/headers/posix/malloc_debug.h @@ -1,5 +1,5 @@ /* - * Copyright 2010 Haiku Inc. All Rights Reserved. + * Copyright 2010-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef MALLOC_DEBUG_H diff --git a/headers/posix/math.h b/headers/posix/math.h index 1089c05d83..df34b2594c 100644 --- a/headers/posix/math.h +++ b/headers/posix/math.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2010 Haiku Inc. All Rights Reserved. + * Copyright 2001-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _MATH_H_ diff --git a/headers/posix/memory.h b/headers/posix/memory.h index f218fba642..16940bbe40 100644 --- a/headers/posix/memory.h +++ b/headers/posix/memory.h @@ -1,8 +1,8 @@ /* - * Copyright 2005-2010 Haiku Inc. All Rights Reserved. + * Copyright 2005-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ - - + + #include diff --git a/headers/posix/monetary.h b/headers/posix/monetary.h index a2877576d4..0624f4c31c 100644 --- a/headers/posix/monetary.h +++ b/headers/posix/monetary.h @@ -1,5 +1,5 @@ /* - * Copyright 2010 Haiku Inc. All Rights Reserved. + * Copyright 2010-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _MONETARY_H_ diff --git a/headers/posix/net/if.h b/headers/posix/net/if.h index fdeff5d579..80522f2bc8 100644 --- a/headers/posix/net/if.h +++ b/headers/posix/net/if.h @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010 Haiku Inc. All Rights Reserved. + * Copyright 2006-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _NET_IF_H diff --git a/headers/posix/net/if_dl.h b/headers/posix/net/if_dl.h index 50bb72250a..b7dc7ad99b 100644 --- a/headers/posix/net/if_dl.h +++ b/headers/posix/net/if_dl.h @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010 Haiku Inc. All Rights Reserved. + * Copyright 2006-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _NET_IF_DL_H diff --git a/headers/posix/net/if_media.h b/headers/posix/net/if_media.h index 4e70897c6a..e0fdc4e76d 100644 --- a/headers/posix/net/if_media.h +++ b/headers/posix/net/if_media.h @@ -1,5 +1,5 @@ /* - * Copyright 2007-2010 Haiku Inc. All Rights Reserved. + * Copyright 2007-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _NET_IF_MEDIA_H diff --git a/headers/posix/net/if_types.h b/headers/posix/net/if_types.h index f954c33048..fda4534f03 100644 --- a/headers/posix/net/if_types.h +++ b/headers/posix/net/if_types.h @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010 Haiku Inc. All Rights Reserved. + * Copyright 2006-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _NET_IF_TYPES_H diff --git a/headers/posix/net/route.h b/headers/posix/net/route.h index 4e021fd620..70e81e8d9e 100644 --- a/headers/posix/net/route.h +++ b/headers/posix/net/route.h @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010 Haiku Inc. All Rights Reserved. + * Copyright 2006-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _NET_ROUTE_H diff --git a/headers/posix/netdb.h b/headers/posix/netdb.h index d29eceed06..c6a6aff208 100644 --- a/headers/posix/netdb.h +++ b/headers/posix/netdb.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ diff --git a/headers/posix/netinet/in.h b/headers/posix/netinet/in.h index c729b738d2..36310d1161 100644 --- a/headers/posix/netinet/in.h +++ b/headers/posix/netinet/in.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _NETINET_IN_H_ diff --git a/headers/posix/netinet/tcp.h b/headers/posix/netinet/tcp.h index 4d3124653a..f865c58239 100644 --- a/headers/posix/netinet/tcp.h +++ b/headers/posix/netinet/tcp.h @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010 Haiku Inc. All Rights Reserved. + * Copyright 2006-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef NETINET_TCP_H @@ -15,7 +15,7 @@ struct tcphdr { uint16_t th_dport; /* destination port */ uint32_t th_seq; uint32_t th_ack; - + #if BIG_ENDIAN uint8_t th_off : 4; /* data offset */ uint8_t th_x2 : 4; /* unused */ diff --git a/headers/posix/netinet6/in6.h b/headers/posix/netinet6/in6.h index 1898617d66..f348d60a27 100644 --- a/headers/posix/netinet6/in6.h +++ b/headers/posix/netinet6/in6.h @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010 Haiku Inc. All Rights Reserved. + * Copyright 2006-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _NETINET6_IN6_H_ diff --git a/headers/posix/nl_types.h b/headers/posix/nl_types.h index 6a91f93fbc..a437a9e328 100644 --- a/headers/posix/nl_types.h +++ b/headers/posix/nl_types.h @@ -1,5 +1,5 @@ /* - * Copyright 2010 Haiku Inc. All Rights Reserved. + * Copyright 2010-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _NL_TYPES_H_ diff --git a/headers/posix/null.h b/headers/posix/null.h index 9d63e4f46e..c74b189c9a 100644 --- a/headers/posix/null.h +++ b/headers/posix/null.h @@ -1,5 +1,5 @@ /* - * Copyright 2008 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _NULL_H diff --git a/headers/posix/poll.h b/headers/posix/poll.h index 3580699c4d..8935f66fae 100644 --- a/headers/posix/poll.h +++ b/headers/posix/poll.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _POLL_H diff --git a/headers/posix/pwd.h b/headers/posix/pwd.h index ea5b604ec6..f08e96c6df 100644 --- a/headers/posix/pwd.h +++ b/headers/posix/pwd.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _PWD_H_ diff --git a/headers/posix/resolv.h b/headers/posix/resolv.h index 7ed5767697..2b1b569b1f 100644 --- a/headers/posix/resolv.h +++ b/headers/posix/resolv.h @@ -1,5 +1,5 @@ /* - * Copyright 2009-2010 Haiku Inc. All Rights Reserved. + * Copyright 2009-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ diff --git a/headers/posix/sched.h b/headers/posix/sched.h index 543c2a3523..c37f757049 100644 --- a/headers/posix/sched.h +++ b/headers/posix/sched.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All rights reserved. + * Copyright 2008-2012 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT license. */ #ifndef _SCHED_H_ diff --git a/headers/posix/search.h b/headers/posix/search.h index 8892c9b4fd..60bb76f77a 100644 --- a/headers/posix/search.h +++ b/headers/posix/search.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SEARCH_H_ @@ -9,9 +9,9 @@ #include -typedef enum { - FIND, - ENTER +typedef enum { + FIND, + ENTER } ACTION; typedef struct entry { diff --git a/headers/posix/semaphore.h b/headers/posix/semaphore.h index 8d6708f360..6be5f81bfb 100644 --- a/headers/posix/semaphore.h +++ b/headers/posix/semaphore.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. + * Copyright 2008-2012 Haiku, Inc. * Distributed under the terms of the MIT License. */ #ifndef _SEMAPHORE_H_ diff --git a/headers/posix/setjmp.h b/headers/posix/setjmp.h index 30b24ea0be..67f4ec04be 100644 --- a/headers/posix/setjmp.h +++ b/headers/posix/setjmp.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2010 Haiku Inc. + * Copyright 2004-2012 Haiku, Inc. * Distributed under the terms of the MIT License. */ #ifndef _SETJMP_H_ diff --git a/headers/posix/shadow.h b/headers/posix/shadow.h index 1866be6a06..ed85ee07ec 100644 --- a/headers/posix/shadow.h +++ b/headers/posix/shadow.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SHADOW_H_ diff --git a/headers/posix/size_t.h b/headers/posix/size_t.h index aaf4bc0cb3..f8235c914f 100644 --- a/headers/posix/size_t.h +++ b/headers/posix/size_t.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SIZE_T_H_ diff --git a/headers/posix/stdint.h b/headers/posix/stdint.h index 37c5e67bd4..eb07104a5a 100644 --- a/headers/posix/stdint.h +++ b/headers/posix/stdint.h @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010 Haiku Inc. All Rights Reserved. + * Copyright 2003-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _STDINT_H_ diff --git a/headers/posix/stdio.h b/headers/posix/stdio.h index aa8fd9e5ef..f5ad972b07 100644 --- a/headers/posix/stdio.h +++ b/headers/posix/stdio.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2010 Haiku Inc. All Rights Reserved. + * Copyright 2004-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _STDIO_H_ diff --git a/headers/posix/stdio_ext.h b/headers/posix/stdio_ext.h index 95d533da0a..fb0c4c28a3 100644 --- a/headers/posix/stdio_ext.h +++ b/headers/posix/stdio_ext.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _STDIO_EXT_H_ diff --git a/headers/posix/stdio_post.h b/headers/posix/stdio_post.h index 83662d8cdf..71a841dfc2 100644 --- a/headers/posix/stdio_post.h +++ b/headers/posix/stdio_post.h @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010 Haiku Inc. All Rights Reserved. + * Copyright 2003-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _STDIO_POST_H_ diff --git a/headers/posix/stdio_pre.h b/headers/posix/stdio_pre.h index 5e973422aa..3d37b86e4d 100644 --- a/headers/posix/stdio_pre.h +++ b/headers/posix/stdio_pre.h @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010 Haiku Inc. All Rights Reserved. + * Copyright 2003-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _STDIO_PRE_H_ diff --git a/headers/posix/stdlib.h b/headers/posix/stdlib.h index efec9062a5..aef3e9184e 100644 --- a/headers/posix/stdlib.h +++ b/headers/posix/stdlib.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _STDLIB_H_ diff --git a/headers/posix/string.h b/headers/posix/string.h index f7e4ab4b1f..d3a9035364 100644 --- a/headers/posix/string.h +++ b/headers/posix/string.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2010 Haiku Inc. All Rights Reserved. + * Copyright 2004-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _STRING_H_ diff --git a/headers/posix/sys/file.h b/headers/posix/sys/file.h index 01839a6236..a7c3384c9d 100644 --- a/headers/posix/sys/file.h +++ b/headers/posix/sys/file.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_FILE_H diff --git a/headers/posix/sys/ioctl.h b/headers/posix/sys/ioctl.h index ee32b3c718..22c3094cfa 100644 --- a/headers/posix/sys/ioctl.h +++ b/headers/posix/sys/ioctl.h @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010 Haiku Inc. All Rights Reserved. + * Copyright 2006-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_IOCTL_H diff --git a/headers/posix/sys/ipc.h b/headers/posix/sys/ipc.h index 2b2cbff93a..90ed41ef87 100644 --- a/headers/posix/sys/ipc.h +++ b/headers/posix/sys/ipc.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_IPC_H diff --git a/headers/posix/sys/mman.h b/headers/posix/sys/mman.h index c5f9f2ce40..a69991ac05 100644 --- a/headers/posix/sys/mman.h +++ b/headers/posix/sys/mman.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_MMAN_H diff --git a/headers/posix/sys/msg.h b/headers/posix/sys/msg.h index 9d5256d9a6..5ab90b46af 100644 --- a/headers/posix/sys/msg.h +++ b/headers/posix/sys/msg.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_MSG_H diff --git a/headers/posix/sys/param.h b/headers/posix/sys/param.h index e28f0239cb..3e5c2b0b66 100644 --- a/headers/posix/sys/param.h +++ b/headers/posix/sys/param.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_PARAM_H diff --git a/headers/posix/sys/poll.h b/headers/posix/sys/poll.h index 529cd331a8..c8f1144ee1 100644 --- a/headers/posix/sys/poll.h +++ b/headers/posix/sys/poll.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_POLL_H diff --git a/headers/posix/sys/resource.h b/headers/posix/sys/resource.h index 66e4c2d597..96ac924a20 100644 --- a/headers/posix/sys/resource.h +++ b/headers/posix/sys/resource.h @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010 Haiku Inc. All Rights Reserved. + * Copyright 2003-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_RESOURCE_H diff --git a/headers/posix/sys/select.h b/headers/posix/sys/select.h index 4a99504312..ebc9d0e49d 100644 --- a/headers/posix/sys/select.h +++ b/headers/posix/sys/select.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_SELECT_H diff --git a/headers/posix/sys/sem.h b/headers/posix/sys/sem.h index 0a80354655..4dc8540005 100644 --- a/headers/posix/sys/sem.h +++ b/headers/posix/sys/sem.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_SEM_H diff --git a/headers/posix/sys/socket.h b/headers/posix/sys/socket.h index 1962acea96..0514d91dda 100644 --- a/headers/posix/sys/socket.h +++ b/headers/posix/sys/socket.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_SOCKET_H @@ -47,7 +47,7 @@ typedef uint32_t socklen_t; #define SOCK_MISC 255 /* Socket options for SOL_SOCKET level */ -#define SOL_SOCKET -1 +#define SOL_SOCKET -1 #define SO_ACCEPTCONN 0x00000001 /* socket has had listen() */ #define SO_BROADCAST 0x00000002 /* permit sending of broadcast msgs */ @@ -85,7 +85,7 @@ struct linger { }; struct sockaddr { - uint8_t sa_len; + uint8_t sa_len; uint8_t sa_family; uint8_t sa_data[30]; }; diff --git a/headers/posix/sys/sockio.h b/headers/posix/sys/sockio.h index 666f05fa76..e486f50241 100644 --- a/headers/posix/sys/sockio.h +++ b/headers/posix/sys/sockio.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_SOCKIO_H @@ -47,9 +47,9 @@ #define SIOCGIFSTATS 8929 /* get interface stats */ #define SIOCGIFTYPE 8931 /* get interface type */ -#define SIOCSPACKETCAP 8932 +#define SIOCSPACKETCAP 8932 /* Start capturing packets on an interface */ -#define SIOCCPACKETCAP 8933 +#define SIOCCPACKETCAP 8933 /* Stop capturing packets on an interface */ #define SIOCSHIWAT 8934 /* set high watermark */ diff --git a/headers/posix/sys/stat.h b/headers/posix/sys/stat.h index 90a10d0d38..358354c6a8 100644 --- a/headers/posix/sys/stat.h +++ b/headers/posix/sys/stat.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_STAT_H_ diff --git a/headers/posix/sys/statvfs.h b/headers/posix/sys/statvfs.h index 916f06083a..4d86ad229c 100644 --- a/headers/posix/sys/statvfs.h +++ b/headers/posix/sys/statvfs.h @@ -1,5 +1,5 @@ /* - * Copyright 2005-2010 Haiku Inc. All Rights Reserved. + * Copyright 2005-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _STAT_VFS_H_ diff --git a/headers/posix/sys/time.h b/headers/posix/sys/time.h index e8606791fc..62f2efee0c 100644 --- a/headers/posix/sys/time.h +++ b/headers/posix/sys/time.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_TIME_H diff --git a/headers/posix/sys/timeb.h b/headers/posix/sys/timeb.h index c338d45d49..e1e2742b8a 100644 --- a/headers/posix/sys/timeb.h +++ b/headers/posix/sys/timeb.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_TIMEB_H diff --git a/headers/posix/sys/times.h b/headers/posix/sys/times.h index 296e814900..bef2d83072 100644 --- a/headers/posix/sys/times.h +++ b/headers/posix/sys/times.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_TIMES_H @@ -21,6 +21,6 @@ extern #ifdef __cplusplus "C" #endif -clock_t times(struct tms *tms); +clock_t times(struct tms *tms); #endif /* _SYS_TIMES_H */ diff --git a/headers/posix/sys/types.h b/headers/posix/sys/types.h index 4a12ba06f8..7ae5450630 100644 --- a/headers/posix/sys/types.h +++ b/headers/posix/sys/types.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_TYPES_H diff --git a/headers/posix/sys/uio.h b/headers/posix/sys/uio.h index ea23c1513b..2e637e40f3 100644 --- a/headers/posix/sys/uio.h +++ b/headers/posix/sys/uio.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_UIO_H diff --git a/headers/posix/sys/un.h b/headers/posix/sys/un.h index 4f55ea4a4a..0cdd5783ae 100644 --- a/headers/posix/sys/un.h +++ b/headers/posix/sys/un.h @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010 Haiku Inc. All Rights Reserved. + * Copyright 2006-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_UN_H @@ -10,7 +10,7 @@ struct sockaddr_un { - uint8_t sun_len; + uint8_t sun_len; uint8_t sun_family; char sun_path[126]; }; diff --git a/headers/posix/sys/utsname.h b/headers/posix/sys/utsname.h index 43fd413871..8b3db846b1 100644 --- a/headers/posix/sys/utsname.h +++ b/headers/posix/sys/utsname.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2010 Haiku Inc. All Rights Reserved. + * Copyright 2004-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_UTSNAME_H diff --git a/headers/posix/syslog.h b/headers/posix/syslog.h index aae1ad8d8c..d0ee5ca577 100644 --- a/headers/posix/syslog.h +++ b/headers/posix/syslog.h @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010 Haiku Inc. All Rights Reserved. + * Copyright 2003-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYSLOG_H_ diff --git a/headers/posix/termios.h b/headers/posix/termios.h index 88db94675a..ccf13ea7c2 100644 --- a/headers/posix/termios.h +++ b/headers/posix/termios.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2010 Haiku Inc. All Rights Reserved. + * Copyright 2004-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _TERMIOS_H_ diff --git a/headers/posix/utime.h b/headers/posix/utime.h index b29d46191b..485eea9b7a 100644 --- a/headers/posix/utime.h +++ b/headers/posix/utime.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Haiku Inc. All Rights Reserved. + * Copyright 2002-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _UTIME_H_ diff --git a/headers/posix/wchar.h b/headers/posix/wchar.h index d2bebb9213..eebc4e5bba 100644 --- a/headers/posix/wchar.h +++ b/headers/posix/wchar.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2011 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _WCHAR_H diff --git a/headers/posix/wchar_t.h b/headers/posix/wchar_t.h index a0b412335a..30077e5791 100644 --- a/headers/posix/wchar_t.h +++ b/headers/posix/wchar_t.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Haiku Inc. All Rights Reserved. + * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ diff --git a/headers/posix/wctype.h b/headers/posix/wctype.h index f71bac7393..00d7776542 100644 --- a/headers/posix/wctype.h +++ b/headers/posix/wctype.h @@ -1,5 +1,5 @@ /* - * Copyright 2005-2011 Haiku Inc. All Rights Reserved. + * Copyright 2005-2012 Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _WCTYPE_H_ From d9879eddbf9e4b01f07679af1769e9f439d4e0ef Mon Sep 17 00:00:00 2001 From: ahenriksson Date: Tue, 17 Jul 2012 21:11:18 +0200 Subject: [PATCH 06/46] A duplicate array with a single value is not allowed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Such arrays could be created by the BFS code between hrev43837 and hrev43924, and cause the array to not be free'd when the entry is removed. The check in _InsertDuplicate() is not changed, as doing an insertion will actually repair this problem. Potentially, the code could be modified to handle this state instead, but since checkfs can fix it, it doesn't seem necessary. Signed-off-by: Axel Dörfler --- src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp b/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp index 90972f37ec..51b896a17b 100644 --- a/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp +++ b/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp @@ -1782,7 +1782,7 @@ BPlusTree::_RemoveDuplicate(Transaction& transaction, bplustree_node::FragmentIndex(oldValue)); int32 arrayCount = array->Count(); - if (arrayCount > NUM_FRAGMENT_VALUES || arrayCount < 1) { + if (arrayCount > NUM_FRAGMENT_VALUES || arrayCount <= 1) { FATAL(("_RemoveDuplicate: Invalid array[%d] size in fragment %" B_PRIdOFF " == %" B_PRId32 ", inode %" B_PRIdOFF "!\n", (int)bplustree_node::FragmentIndex(oldValue), duplicateOffset, @@ -2361,7 +2361,7 @@ BPlusTree::_ValidateChildren(TreeCheck& check, uint32 level, off_t offset, } int32 arrayCount = array->Count(); - if (arrayCount < 1 || arrayCount > maxSize) { + if (arrayCount <= 1 || arrayCount > maxSize) { dprintf("inode %" B_PRIdOFF ": duplicate at %" B_PRIdOFF " has invalid array size %" B_PRId32 "!\n", fStream->ID(), duplicateOffset, arrayCount); From 02378956042046a9fc635820f73d2cbeb7a4b5df Mon Sep 17 00:00:00 2001 From: ahenriksson Date: Tue, 17 Jul 2012 21:23:22 +0200 Subject: [PATCH 07/46] CheckBlocks() calculated the group block incorrectly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Axel Dörfler --- src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp b/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp index 8dc8f3f4b0..b0d446f75b 100644 --- a/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp +++ b/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp @@ -1699,9 +1699,11 @@ BlockAllocator::CheckBlocks(off_t start, off_t length, bool allocated) if (start < 0 || start + length > fVolume->NumBlocks()) return B_BAD_VALUE; - uint32 group = start >> fVolume->AllocationGroupShift(); - uint32 groupBlock = start / (fVolume->BlockSize() << 3); - uint32 blockOffset = start % fVolume->BlockSize(); + int32 group = start >> fVolume->AllocationGroupShift(); + uint32 bitmapBlock = start / (fVolume->BlockSize() << 3); + uint32 blockOffset = start % (fVolume->BlockSize() << 3); + + uint32 groupBlock = bitmapBlock % fBlocksPerGroup; AllocationBlock cached(fVolume); From 1f80f2eec3fcca13f5d0f4e146bde2058672a0ab Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Thu, 19 Jul 2012 20:21:06 -0400 Subject: [PATCH 08/46] Fix #8749. - When a job needs to go dependent on another job, we no longer use recursion to manage the execution stack. Instead the job is simply marked as waiting and we execute other jobs with no dependencies in the meantime. When a job completes, all dependents are moved back onto the unscheduled list and executed as needed. - Adjustments to ResolveValueNodeJob to handle the now asynchronous nature of waiting. --- src/apps/debugger/Jobs.cpp | 6 +++++ src/apps/debugger/Worker.cpp | 45 +++++++++++++++++------------------- src/apps/debugger/Worker.h | 2 +- 3 files changed, 28 insertions(+), 25 deletions(-) diff --git a/src/apps/debugger/Jobs.cpp b/src/apps/debugger/Jobs.cpp index 0e812cc114..bfd2fe11dc 100644 --- a/src/apps/debugger/Jobs.cpp +++ b/src/apps/debugger/Jobs.cpp @@ -1,4 +1,5 @@ /* + * Copyright 2012, Rene Gollent, rene@gollent.com. * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -523,6 +524,9 @@ ResolveValueNodeValueJob::_ResolveNodeValue() fValueNode, fValueNode->Name().String(), parentNode); return error; } + + if (State() == JOB_STATE_WAITING) + return B_OK; } // resolve the node child location, if necessary @@ -629,6 +633,8 @@ ResolveValueNodeValueJob::_ResolveParentNodeValue(ValueNode* parentNode) // "Not found" can happen due to a race condition between // unlocking the worker and starting to wait. break; + case JOB_DEPENDENCY_ACTIVE: + return B_OK; case JOB_DEPENDENCY_FAILED: case JOB_DEPENDENCY_ABORTED: default: diff --git a/src/apps/debugger/Worker.cpp b/src/apps/debugger/Worker.cpp index dc1f06af09..409ff2b5b9 100644 --- a/src/apps/debugger/Worker.cpp +++ b/src/apps/debugger/Worker.cpp @@ -1,4 +1,5 @@ /* + * Copyright 2012, Rene Gollent, rene@gollent.com. * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -138,6 +139,15 @@ void Job::SetWaitStatus(job_wait_status status) { fWaitStatus = status; + switch (fWaitStatus) { + case JOB_DEPENDENCY_ACTIVE: + fState = JOB_STATE_WAITING; + break; + default: + fState = JOB_STATE_ACTIVE; + break; + + } } @@ -346,18 +356,6 @@ Worker::WaitForJob(Job* waitingJob, const JobKey& key) waitingJob->SetDependency(job); job->DependentJobs().Add(waitingJob); - // TODO: Continuations would be nice. For the time being we have to use - // recursion. Disadvantages are that we'll use more stack and that aborting - // a job waiting for a dependency won't abort the job before the dependency - // is done. - locker.Unlock(); - _ProcessJobs(waitingJob); - locker.Lock(); - - // ignore the actual wait status when the game is over anyway - if (fTerminating || waitingJob->State() == JOB_STATE_ABORTED) - return JOB_DEPENDENCY_ABORTED; - return waitingJob->WaitStatus(); } @@ -372,7 +370,7 @@ Worker::_WorkerLoopEntry(void* data) status_t Worker::_WorkerLoop() { - _ProcessJobs(NULL); + _ProcessJobs(); // clean up aborted jobs AutoLocker locker(this); @@ -384,7 +382,7 @@ Worker::_WorkerLoop() void -Worker::_ProcessJobs(Job* waitingJob) +Worker::_ProcessJobs() { while (true) { AutoLocker locker(this); @@ -395,8 +393,10 @@ Worker::_ProcessJobs(Job* waitingJob) status_t error = acquire_sem(fWorkToDoSem); if (error != B_OK) { - if (error == B_INTERRUPTED) + if (error == B_INTERRUPTED) { + locker.Lock(); continue; + } break; } @@ -404,13 +404,9 @@ Worker::_ProcessJobs(Job* waitingJob) } // clean up aborted jobs - while (Job* job = fAbortedJobs.RemoveHead()) { + while (Job* job = fAbortedJobs.RemoveHead()) _FinishJob(job); - if (waitingJob != NULL && waitingJob->State() != JOB_STATE_WAITING) - break; - } - // process the next job if (Job* job = fUnscheduledJobs.RemoveHead()) { job->SetState(JOB_STATE_ACTIVE); @@ -422,12 +418,10 @@ Worker::_ProcessJobs(Job* waitingJob) if (job->State() == JOB_STATE_ACTIVE) { job->SetState( error == B_OK ? JOB_STATE_SUCCEEDED : JOB_STATE_FAILED); - } + } else if (job->State() == JOB_STATE_WAITING) + continue; _FinishJob(job); - - if (waitingJob != NULL && waitingJob->State() != JOB_STATE_WAITING) - break; } } } @@ -492,7 +486,10 @@ Worker::_FinishJob(Job* job) while (Job* dependentJob = job->DependentJobs().RemoveHead()) { dependentJob->SetDependency(NULL); dependentJob->SetWaitStatus(waitStatus); + fUnscheduledJobs.Add(dependentJob); } + + release_sem(fWorkToDoSem); } if (job->State() != JOB_STATE_ABORTED) diff --git a/src/apps/debugger/Worker.h b/src/apps/debugger/Worker.h index 241a3f4afa..7e356992a7 100644 --- a/src/apps/debugger/Worker.h +++ b/src/apps/debugger/Worker.h @@ -182,7 +182,7 @@ private: static status_t _WorkerLoopEntry(void* data); status_t _WorkerLoop(); - void _ProcessJobs(Job* waitingJob); + void _ProcessJobs(); void _AbortJob(Job* job, bool removeFromTable); void _FinishJob(Job* job); From 0b4ae860860072dfbca7f50bdad5ab5e232bab72 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Thu, 19 Jul 2012 20:58:57 -0400 Subject: [PATCH 09/46] Fix #8751 and possibly also #7198. - The cdrecord port was using the wrong path for searching for SCSI devices. This led to it failing to find SATA CD drives. Updated package by Chris Roberts. --- build/jam/OptionalPackageDependencies | 2 +- build/jam/OptionalPackages | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build/jam/OptionalPackageDependencies b/build/jam/OptionalPackageDependencies index aa4a525d3b..9bca225c2e 100644 --- a/build/jam/OptionalPackageDependencies +++ b/build/jam/OptionalPackageDependencies @@ -10,7 +10,7 @@ OptionalPackageDependencies ArmyKnife : TagLib ; OptionalPackageDependencies Beam : LibIconv LibLayout OpenSSL PCRE ; OptionalPackageDependencies BeHappy : BeBook NetSurf ; OptionalPackageDependencies BurnItNow : CDRecord ; -OptionalPackageDependencies CDRecord : LibIconv ; +OptionalPackageDependencies CDRecord : GetText LibIconv ; OptionalPackageDependencies Curl : OpenSSL ; OptionalPackageDependencies DevelopmentBase : CDRecord DevelopmentMin Yasm ; OptionalPackageDependencies Development : DevelopmentBase Perl ; diff --git a/build/jam/OptionalPackages b/build/jam/OptionalPackages index f4b3dd97b6..caf1e5e71a 100644 --- a/build/jam/OptionalPackages +++ b/build/jam/OptionalPackages @@ -409,12 +409,12 @@ if [ IsOptionalHaikuImagePackageAdded CDRecord ] { Echo "No optional package CDRecord available for $(TARGET_ARCH)" ; } else if $(HAIKU_GCC_VERSION[1]) >= 4 { InstallOptionalHaikuImagePackage - cdrtools-3.01a06-x86-gcc4-2012-06-19.zip - : $(baseURL)/cdrtools-3.01a06-x86-gcc4-2012-06-19.zip ; + cdrtools-3.01a07-x86-gcc4-2012-06-19.zip + : $(baseURL)/cdrtools-3.01a07-x86-gcc4-2012-07-19.zip ; } else { InstallOptionalHaikuImagePackage - cdrtools-3.01a06-x86-gcc2-2012-06-20.zip - : $(baseURL)/cdrtools-3.01a06-x86-gcc2-2012-06-20.zip ; + cdrtools-3.01a07-x86-gcc2-2012-07-19-r2.zip + : $(baseURL)/cdrtools-3.01a07-x86-gcc2-2012-07-19-r2.zip ; } } From fe0407cd4604f8c1fe33d3ca436daeae112173b7 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Fri, 20 Jul 2012 07:34:11 -0400 Subject: [PATCH 10/46] Fix indentation. --- src/apps/debugger/Worker.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/apps/debugger/Worker.cpp b/src/apps/debugger/Worker.cpp index 409ff2b5b9..304c3bd033 100644 --- a/src/apps/debugger/Worker.cpp +++ b/src/apps/debugger/Worker.cpp @@ -140,13 +140,12 @@ Job::SetWaitStatus(job_wait_status status) { fWaitStatus = status; switch (fWaitStatus) { - case JOB_DEPENDENCY_ACTIVE: - fState = JOB_STATE_WAITING; - break; - default: - fState = JOB_STATE_ACTIVE; - break; - + case JOB_DEPENDENCY_ACTIVE: + fState = JOB_STATE_WAITING; + break; + default: + fState = JOB_STATE_ACTIVE; + break; } } From fc4d98a2c09fcc8e96eda3f9a234ae9cd71dba48 Mon Sep 17 00:00:00 2001 From: Philippe Saint-Pierre Date: Fri, 20 Jul 2012 14:28:44 -0400 Subject: [PATCH 11/46] Coding style fixes, no functionnal changes. Following comments from Axel about a previous commit of mine. Sorry Axel for the delay. --- src/apps/codycam/CodyCam.cpp | 3 +-- src/apps/icon-o-matic/IconEditorApp.cpp | 4 ++-- src/apps/mediaconverter/MediaConverterWindow.cpp | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/apps/codycam/CodyCam.cpp b/src/apps/codycam/CodyCam.cpp index 0df1c060a6..2b79880cd9 100644 --- a/src/apps/codycam/CodyCam.cpp +++ b/src/apps/codycam/CodyCam.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -23,8 +24,6 @@ #include #include -#include - #undef B_TRANSLATION_CONTEXT #define B_TRANSLATION_CONTEXT "CodyCam" diff --git a/src/apps/icon-o-matic/IconEditorApp.cpp b/src/apps/icon-o-matic/IconEditorApp.cpp index 27f73a9484..69d3b54439 100644 --- a/src/apps/icon-o-matic/IconEditorApp.cpp +++ b/src/apps/icon-o-matic/IconEditorApp.cpp @@ -13,12 +13,12 @@ #include #include #include +#include #include #include #include #include #include -#include #include "support_settings.h" @@ -331,7 +331,7 @@ IconEditorApp::_LastFilePath(path_kind which) path = fLastOpenPath.String(); break; } - if (!path) { + if (path == NULL) { BPath homePath; if (find_directory(B_USER_DIRECTORY, &homePath) == B_OK) diff --git a/src/apps/mediaconverter/MediaConverterWindow.cpp b/src/apps/mediaconverter/MediaConverterWindow.cpp index d97dcb1b0e..c6288660d2 100644 --- a/src/apps/mediaconverter/MediaConverterWindow.cpp +++ b/src/apps/mediaconverter/MediaConverterWindow.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -31,8 +32,6 @@ #include #include -#include - #include "MediaFileInfoView.h" #include "MediaFileListView.h" #include "MessageConstants.h" From af350aa21891c6d37934df7686e2cba1d0f4f29f Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Fri, 20 Jul 2012 23:24:33 +0200 Subject: [PATCH 12/46] Add private shared class ArgumentVector The parser is based on the FS shell's ArgVector. --- headers/private/shared/ArgumentVector.h | 53 +++++++ src/kits/shared/ArgumentVector.cpp | 203 ++++++++++++++++++++++++ src/kits/shared/Jamfile | 1 + 3 files changed, 257 insertions(+) create mode 100644 headers/private/shared/ArgumentVector.h create mode 100644 src/kits/shared/ArgumentVector.cpp diff --git a/headers/private/shared/ArgumentVector.h b/headers/private/shared/ArgumentVector.h new file mode 100644 index 0000000000..0b32a8743d --- /dev/null +++ b/headers/private/shared/ArgumentVector.h @@ -0,0 +1,53 @@ +/* + * Copyright 2007-2012, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef _ARGUMENT_VECTOR_H +#define _ARGUMENT_VECTOR_H + + +#include + + +namespace BPrivate { + + +class ArgumentVector { +public: + enum ParseError { + NO_ERROR, + NO_MEMORY, + UNTERMINATED_QUOTED_STRING, + TRAILING_BACKSPACE + }; + +public: + ArgumentVector(); + ~ArgumentVector(); + + int32 ArgumentCount() const { return fCount; } + const char* const* Arguments() const { return fArguments; } + + char** DetachArguments(); + // Caller must free() -- it's all one big allocation at the + // returned pointer. + + ParseError Parse(const char* commandLine, + const char** _errorLocation = NULL); + +private: + struct Parser; + +private: + char** fArguments; + int32 fCount; +}; + + +} // namespace BPrivate + + +using BPrivate::ArgumentVector; + + +#endif // _ARGUMENT_VECTOR_H diff --git a/src/kits/shared/ArgumentVector.cpp b/src/kits/shared/ArgumentVector.cpp new file mode 100644 index 0000000000..c678f5de7c --- /dev/null +++ b/src/kits/shared/ArgumentVector.cpp @@ -0,0 +1,203 @@ +/* + * Copyright 2007-2012, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ + + +#include + +#include +#include + +#include +#include + + +struct ArgumentVector::Parser { + ParseError Parse(const char* commandLine, const char*& _errorLocation) + { + // init temporary arg/argv storage + fCurrentArg.clear(); + fCurrentArgStarted = false; + fArgVector.clear(); + fTotalStringSize = 0; + + for (; *commandLine; commandLine++) { + char c = *commandLine; + + // whitespace delimits args and is otherwise ignored + if (isspace(c)) { + _PushCurrentArg(); + continue; + } + + const char* errorBase = commandLine; + + switch (c) { + case '\'': + // quoted string -- no quoting + while (*++commandLine != '\'') { + c = *commandLine; + if (c == '\0') { + _errorLocation = errorBase; + return UNTERMINATED_QUOTED_STRING; + } + _PushCharacter(c); + } + break; + + case '"': + // quoted string -- some quoting + while (*++commandLine != '"') { + c = *commandLine; + if (c == '\0') { + _errorLocation = errorBase; + return UNTERMINATED_QUOTED_STRING; + } + + if (c == '\\') { + c = *++commandLine; + if (c == '\0') { + _errorLocation = errorBase; + return UNTERMINATED_QUOTED_STRING; + } + + // only '\' and '"' can be quoted, otherwise the + // the '\' is treated as a normal char + if (c != '\\' && c != '"') + _PushCharacter('\\'); + } + + _PushCharacter(c); + } + break; + + case '\\': + // quoted char + c = *++commandLine; + if (c == '\0') { + _errorLocation = errorBase; + return TRAILING_BACKSPACE; + } + _PushCharacter(c); + break; + + default: + // normal char + _PushCharacter(c); + break; + } + } + + // commit last arg + _PushCurrentArg(); + + return NO_ERROR; + } + + const std::vector& ArgVector() const + { + return fArgVector; + } + + size_t TotalStringSize() const + { + return fTotalStringSize; + } + +private: + void _PushCurrentArg() + { + if (fCurrentArgStarted) { + fArgVector.push_back(fCurrentArg); + fTotalStringSize += fCurrentArg.length() + 1; + fCurrentArgStarted = false; + } + } + + void _PushCharacter(char c) + { + if (!fCurrentArgStarted) { + fCurrentArg = ""; + fCurrentArgStarted = true; + } + + fCurrentArg += c; + } + +private: + // temporaries + std::string fCurrentArg; + bool fCurrentArgStarted; + std::vector fArgVector; + size_t fTotalStringSize; +}; + + +ArgumentVector::ArgumentVector() + : + fArguments(NULL), + fCount(0) +{ +} + + +ArgumentVector::~ArgumentVector() +{ + free(fArguments); +} + + +char** +ArgumentVector::DetachArguments() +{ + char** arguments = fArguments; + fArguments = NULL; + fCount = 0; + return arguments; +} + + +ArgumentVector::ParseError +ArgumentVector::Parse(const char* commandLine, const char** _errorLocation) +{ + free(DetachArguments()); + + ParseError error; + const char* errorLocation = commandLine; + + try { + Parser parser; + error = parser.Parse(commandLine, errorLocation); + + if (error == NO_ERROR) { + // Create a char* array and copy everything into a single + // allocation. + int count = parser.ArgVector().size(); + size_t arraySize = (count + 1) * sizeof(char*); + fArguments = (char**)malloc( + arraySize + parser.TotalStringSize()); + if (fArguments != 0) { + char* argument = (char*)(fArguments + count + 1); + for (int i = 0; i < count; i++) { + fArguments[i] = argument; + const std::string& sourceArgument = parser.ArgVector()[i]; + size_t argumentSize = sourceArgument.length() + 1; + memcpy(argument, sourceArgument.c_str(), argumentSize); + argument += argumentSize; + } + + fArguments[count] = NULL; + fCount = count; + } else + error = NO_MEMORY; + } + } catch (...) { + error = NO_MEMORY; + } + + if (error != NO_ERROR && _errorLocation != NULL) + *_errorLocation = errorLocation; + + return error; +} diff --git a/src/kits/shared/Jamfile b/src/kits/shared/Jamfile index d56a8b6fe2..8992caa24f 100644 --- a/src/kits/shared/Jamfile +++ b/src/kits/shared/Jamfile @@ -15,6 +15,7 @@ UsePrivateHeaders kernel libroot ; StaticLibrary libshared.a : AboutMenuItem.cpp AboutWindow.cpp + ArgumentVector.cpp CalendarView.cpp ColorQuantizer.cpp CommandPipe.cpp From 0f1f968ffb6f4b19193ccad1a4edae9e9a46ab19 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Fri, 20 Jul 2012 23:26:14 +0200 Subject: [PATCH 13/46] Debugger: Actually create the CLI, if requested --- src/apps/debugger/Debugger.cpp | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/apps/debugger/Debugger.cpp b/src/apps/debugger/Debugger.cpp index c7a687c855..f5617470aa 100644 --- a/src/apps/debugger/Debugger.cpp +++ b/src/apps/debugger/Debugger.cpp @@ -56,7 +56,7 @@ static const char* kUsage = "\n" "Options:\n" " -h, --help - Print this usage info and exit.\n" - " -c, --cli - Use command line user interface (not yet implemented)\n" + " -c, --cli - Use command line user interface\n" ; @@ -397,7 +397,8 @@ Debugger::ArgvReceived(int32 argc, char** argv) return; } - start_team_debugger(team, &fSettingsManager, this, thread, stopInMain); + start_team_debugger(team, &fSettingsManager, this, thread, stopInMain, + options.useCLI); } @@ -481,6 +482,7 @@ Debugger::_FindTeamDebugger(team_id teamID) const // #pragma mark - + int main(int argc, const char* const* argv) { @@ -493,20 +495,15 @@ main(int argc, const char* const* argv) Options options; parse_arguments(argc, argv, false, options); - if (options.useCLI) { - // TODO: implement - fprintf(stderr, "Error: Command line interface unimplemented\n"); + Debugger app; + status_t error = app.Init(); + if (error != B_OK) { + fprintf(stderr, "Error: Failed to init application: %s\n", + strerror(error)); return 1; - } else { - Debugger app; - status_t error = app.Init(); - if (error != B_OK) { - fprintf(stderr, "Error: Failed to init application: %s\n", - strerror(error)); - return 1; - } - - app.Run(); } + + app.Run(); + return 0; } From 6d60b554e6d6cee2a7e73e95b5e06374c9f2e32f Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Fri, 20 Jul 2012 23:30:34 +0200 Subject: [PATCH 14/46] Debugger: Some basic work to get the CLI going There's an input loop thread which reads and parses command lines and the infrastructure for registering and executing commands. Currently only "help" and "quit" commands are implemented. --- src/apps/debugger/Jamfile | 7 +- .../user_interface/cli/CliCommand.cpp | 20 ++ .../debugger/user_interface/cli/CliCommand.h | 33 +++ .../debugger/user_interface/cli/CliContext.h | 13 + .../cli/CommandLineUserInterface.cpp | 236 +++++++++++++++++- .../cli/CommandLineUserInterface.h | 35 +++ 6 files changed, 338 insertions(+), 6 deletions(-) create mode 100644 src/apps/debugger/user_interface/cli/CliCommand.cpp create mode 100644 src/apps/debugger/user_interface/cli/CliCommand.h create mode 100644 src/apps/debugger/user_interface/cli/CliContext.h diff --git a/src/apps/debugger/Jamfile b/src/apps/debugger/Jamfile index 193bc20961..80c98fe660 100644 --- a/src/apps/debugger/Jamfile +++ b/src/apps/debugger/Jamfile @@ -169,12 +169,13 @@ Application Debugger : # user_interface UserInterface.cpp + # user_interface/cli + CliCommand.cpp + CommandLineUserInterface.cpp + # user_interface/gui GraphicalUserInterface.cpp - # user_interface/cli - CommandLineUserInterface.cpp - # user_interface/gui/model VariablesViewState.cpp VariablesViewStateHistory.cpp diff --git a/src/apps/debugger/user_interface/cli/CliCommand.cpp b/src/apps/debugger/user_interface/cli/CliCommand.cpp new file mode 100644 index 0000000000..c83c8cfbad --- /dev/null +++ b/src/apps/debugger/user_interface/cli/CliCommand.cpp @@ -0,0 +1,20 @@ +/* + * Copyright 2012, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ + + +#include "CliCommand.h" + + +CliCommand::CliCommand(const char* summary, const char* usage) + : + fSummary(summary), + fUsage(usage) +{ +} + + +CliCommand::~CliCommand() +{ +} diff --git a/src/apps/debugger/user_interface/cli/CliCommand.h b/src/apps/debugger/user_interface/cli/CliCommand.h new file mode 100644 index 0000000000..2a65e19aa3 --- /dev/null +++ b/src/apps/debugger/user_interface/cli/CliCommand.h @@ -0,0 +1,33 @@ +/* + * Copyright 2012, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef CLI_COMMAND_H +#define CLI_COMMAND_H + + +#include + + +class CliContext; + + +class CliCommand : public BReferenceable { +public: + CliCommand(const char* summary, + const char* usage); + virtual ~CliCommand(); + + const char* Summary() const { return fSummary; } + const char* Usage() const { return fUsage; } + + virtual void Execute(int argc, const char* const* argv, + CliContext& context) = 0; + +private: + const char* fSummary; + const char* fUsage; +}; + + +#endif // CLI_COMMAND_H diff --git a/src/apps/debugger/user_interface/cli/CliContext.h b/src/apps/debugger/user_interface/cli/CliContext.h new file mode 100644 index 0000000000..df318160a9 --- /dev/null +++ b/src/apps/debugger/user_interface/cli/CliContext.h @@ -0,0 +1,13 @@ +/* + * Copyright 2012, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef CLI_CONTEXT_H +#define CLI_CONTEXT_H + + +class CliContext { +}; + + +#endif // CLI_CONTEXT_H diff --git a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp index 95fd5f29fb..ab53011fb2 100644 --- a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp +++ b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp @@ -1,13 +1,106 @@ /* * Copyright 2011, Rene Gollent, rene@gollent.com. + * Copyright 2012, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ #include "CommandLineUserInterface.h" +#include + +#include + +#include +#include + +#include "CliCommand.h" +#include "CliContext.h" + + +// #pragma mark - CommandEntry + + +struct CommandLineUserInterface::CommandEntry { + CommandEntry(const BString& name, CliCommand* command) + : + fName(name), + fCommand(command) + { + } + + const BString& Name() const + { + return fName; + } + + CliCommand* Command() const + { + return fCommand.Get(); + } + +private: + BString fName; + BReference fCommand; +}; + + +// #pragma mark - HelpCommand + + +struct CommandLineUserInterface::HelpCommand : CliCommand { + HelpCommand(CommandLineUserInterface* userInterface) + : + CliCommand("print a list of all commands", + "%s\n" + "Prints a list of all commands."), + fUserInterface(userInterface) + { + } + + virtual void Execute(int argc, const char* const* argv, CliContext& context) + { + fUserInterface->_PrintHelp(); + } + +private: + CommandLineUserInterface* fUserInterface; +}; + + +// #pragma mark - HelpCommand + + +struct CommandLineUserInterface::QuitCommand : CliCommand { + QuitCommand(CommandLineUserInterface* userInterface) + : + CliCommand("quit Debugger", + "%s\n" + "Quits Debugger."), + fUserInterface(userInterface) + { + } + + virtual void Execute(int argc, const char* const* argv, CliContext& context) + { + fUserInterface->fListener->UserInterfaceQuitRequested(); + } + +private: + CommandLineUserInterface* fUserInterface; +}; + + +// #pragma mark - CommandLineUserInterface + CommandLineUserInterface::CommandLineUserInterface() + : + fThread(-1), + fTeam(NULL), + fListener(NULL), + fCommands(20, true), + fTerminating(false) { } @@ -27,33 +120,48 @@ CommandLineUserInterface::ID() const status_t CommandLineUserInterface::Init(Team* team, UserInterfaceListener* listener) { - return B_UNSUPPORTED; + fTeam = team; + fListener = listener; + + status_t error = _RegisterCommands(); + if (error != B_OK) + return error; + + fThread = spawn_thread(&_InputLoopEntry, "CLI", B_NORMAL_PRIORITY, this); + if (fThread < 0) + return fThread; + + return B_OK; } void CommandLineUserInterface::Show() { + resume_thread(fThread); } void CommandLineUserInterface::Terminate() { + fTerminating = true; + // TODO: Signal the thread so it wakes up! + wait_for_thread(fThread, NULL); } status_t CommandLineUserInterface::LoadSettings(const TeamUISettings* settings) { - return B_UNSUPPORTED; + return B_OK; } status_t CommandLineUserInterface::SaveSettings(TeamUISettings*& settings) const { - return B_UNSUPPORTED;; + return B_OK; } @@ -71,3 +179,125 @@ CommandLineUserInterface::SynchronouslyAskUser(const char* title, { return 0; } + + +/*static*/ status_t +CommandLineUserInterface::_InputLoopEntry(void* data) +{ + return ((CommandLineUserInterface*)data)->_InputLoop(); +} + + +status_t +CommandLineUserInterface::_InputLoop() +{ + while (!fTerminating) { + // read a command line + printf("debugger> "); + fflush(stdout); + char buffer[256]; + if (fgets(buffer, sizeof(buffer), stdin) == NULL) + break; + + // parse the command line + ArgumentVector args; + const char* parseErrorLocation; + switch (args.Parse(buffer, &parseErrorLocation)) { + case ArgumentVector::NO_ERROR: + break; + case ArgumentVector::NO_MEMORY: + printf("Insufficient memory parsing the command line.\n"); + continue; + case ArgumentVector::UNTERMINATED_QUOTED_STRING: + printf("Parse error: Unterminated quoted string starting at " + "character %zu.\n", parseErrorLocation - buffer + 1); + continue; + case ArgumentVector::TRAILING_BACKSPACE: + printf("Parse error: trailing backspace.\n"); + continue; + } + + if (args.ArgumentCount() == 0) + continue; + + _ExecuteCommand(args.ArgumentCount(), args.Arguments()); + } + + return B_OK; +} + + +status_t +CommandLineUserInterface::_RegisterCommands() +{ + if (_RegisterCommand("help", new(std::nothrow) HelpCommand(this)) && + _RegisterCommand("quit", new(std::nothrow) QuitCommand(this))) { + return B_OK; + } + + return B_NO_MEMORY; +} + + +bool +CommandLineUserInterface::_RegisterCommand(const BString& name, + CliCommand* command) +{ + BReference commandReference(command, true); + if (name.IsEmpty() || command == NULL) + return false; + + CommandEntry* entry = new(std::nothrow) CommandEntry(name, command); + if (entry == NULL || !fCommands.AddItem(entry)) { + delete entry; + return false; + } + + return true; +} + + +void +CommandLineUserInterface::_ExecuteCommand(int argc, const char* const* argv) +{ + const char* commandName = argv[0]; + size_t commandNameLength = strlen(commandName); + + CommandEntry* firstEntry = NULL; + for (int32 i = 0; CommandEntry* entry = fCommands.ItemAt(i); i++) { + if (entry->Name().Compare(commandName, commandNameLength) == 0) { + if (firstEntry != NULL) { + printf("Ambiguous command \"%s\".\n", commandName); + return; + } + + firstEntry = entry; + } + } + + if (firstEntry == NULL) { + printf("Unknown command \"%s\".\n", commandName); + return; + } + + CliContext context; + firstEntry->Command()->Execute(argc, argv, context); +} + + +void +CommandLineUserInterface::_PrintHelp() +{ + // determine longest command name + int32 longestCommandName = 0; + for (int32 i = 0; CommandEntry* entry = fCommands.ItemAt(i); i++) { + longestCommandName + = std::max(longestCommandName, entry->Name().Length()); + } + + // print the command list + for (int32 i = 0; CommandEntry* entry = fCommands.ItemAt(i); i++) { + printf("%*s - %s\n", (int)longestCommandName, entry->Name().String(), + entry->Command()->Summary()); + } +} diff --git a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h index 4d04a7c2ee..b581f36b90 100644 --- a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h +++ b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h @@ -1,14 +1,21 @@ /* * Copyright 2011, Rene Gollent, rene@gollent.com. + * Copyright 2012, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ #ifndef COMMAND_LINE_USER_INTERFACE_H #define COMMAND_LINE_USER_INTERFACE_H +#include +#include + #include "UserInterface.h" +class CliCommand; + + class CommandLineUserInterface : public UserInterface { public: CommandLineUserInterface(); @@ -33,6 +40,34 @@ public: const char* message, const char* choice1, const char* choice2, const char* choice3); +private: + struct CommandEntry; + typedef BObjectList CommandList; + + struct HelpCommand; + struct QuitCommand; + + // GCC 2 support + friend struct HelpCommand; + friend struct QuitCommand; + +private: + static status_t _InputLoopEntry(void* data); + status_t _InputLoop(); + + status_t _RegisterCommands(); + bool _RegisterCommand(const BString& name, + CliCommand* command); + void _ExecuteCommand(int argc, + const char* const* argv); + void _PrintHelp(); + +private: + thread_id fThread; + Team* fTeam; + UserInterfaceListener* fListener; + CommandList fCommands; + bool fTerminating; }; From 739ed61c38bf8e712f6c9b88c20ed5a860acfc00 Mon Sep 17 00:00:00 2001 From: Philippe Saint-Pierre Date: Fri, 20 Jul 2012 15:21:30 -0400 Subject: [PATCH 15/46] CID 709703: Order of ops was unclear, but insignificant --- src/apps/webpositive/tabview/TabContainerView.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apps/webpositive/tabview/TabContainerView.cpp b/src/apps/webpositive/tabview/TabContainerView.cpp index 52217fa9c7..7f231e1d9c 100644 --- a/src/apps/webpositive/tabview/TabContainerView.cpp +++ b/src/apps/webpositive/tabview/TabContainerView.cpp @@ -140,7 +140,7 @@ TabContainerView::MouseDown(BPoint where) // Middle click outside tabs should always open a new tab. fClickCount = 2; } else if (clicks > 1) - fClickCount = fClickCount++; + fClickCount++; else fClickCount = 1; } From c6df3cf4dc01fa0e77abd093d717ecdbee87f465 Mon Sep 17 00:00:00 2001 From: Philippe Saint-Pierre Date: Fri, 20 Jul 2012 15:34:16 -0400 Subject: [PATCH 16/46] CID 702244: Uninit members were never used --- src/apps/icon-o-matic/CanvasView.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/apps/icon-o-matic/CanvasView.h b/src/apps/icon-o-matic/CanvasView.h index b022ca3555..57dfa94dbf 100644 --- a/src/apps/icon-o-matic/CanvasView.h +++ b/src/apps/icon-o-matic/CanvasView.h @@ -118,9 +118,6 @@ private: BPoint fScrollOffsetStart; uint32 fMouseFilterMode; - - BBitmap* fOffsreenBitmap; - BView* fOffsreenView; }; #endif // CANVAS_VIEW_H From cd383c3378a59c29329c5c8f47bb4d9ed93854b8 Mon Sep 17 00:00:00 2001 From: Philippe Saint-Pierre Date: Fri, 20 Jul 2012 15:51:57 -0400 Subject: [PATCH 17/46] CID 610802: Unchecked return of FindMessage() --- src/apps/icon-o-matic/IconEditorApp.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/apps/icon-o-matic/IconEditorApp.cpp b/src/apps/icon-o-matic/IconEditorApp.cpp index 69d3b54439..d667ce90ce 100644 --- a/src/apps/icon-o-matic/IconEditorApp.cpp +++ b/src/apps/icon-o-matic/IconEditorApp.cpp @@ -372,7 +372,11 @@ IconEditorApp::_RestoreSettings() // Compensate offset for next window... fLastWindowFrame.OffsetBy(-kWindowOffset, -kWindowOffset); } - settings.FindMessage("window settings", &fLastWindowSettings); + BMessage lastSettings; + if (settings.FindMessage("window settings", &lastSettings) + == B_OK) { + fLastWindowSettings = lastSettings; + } int32 mode; if (settings.FindInt32("export mode", &mode) >= B_OK) From a65ef315855554757c1d65ab807d7969cf485257 Mon Sep 17 00:00:00 2001 From: Philippe Saint-Pierre Date: Fri, 20 Jul 2012 16:28:56 -0400 Subject: [PATCH 18/46] CID 609036: Avoid to exceed length of string --- src/system/libroot/posix/syslog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/system/libroot/posix/syslog.cpp b/src/system/libroot/posix/syslog.cpp index ca50038cd2..7ed66d97de 100644 --- a/src/system/libroot/posix/syslog.cpp +++ b/src/system/libroot/posix/syslog.cpp @@ -215,7 +215,7 @@ void openlog_team(const char *ident, int options, int facility) { if (ident != NULL) - strcpy(sTeamContext.ident, ident); + strlcpy(sTeamContext.ident, ident, sizeof(sTeamContext.ident)); sTeamContext.options = options; sTeamContext.facility = SYSLOG_FACILITY(facility); From 8f226f2e879cd42bdeee49585b50033e7b0e967e Mon Sep 17 00:00:00 2001 From: Philippe Saint-Pierre Date: Fri, 20 Jul 2012 17:19:07 -0400 Subject: [PATCH 19/46] CID 602195: use sizeof() of structure rather than pointer --- src/add-ons/kernel/file_systems/ntfs/ntfsdir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/add-ons/kernel/file_systems/ntfs/ntfsdir.c b/src/add-ons/kernel/file_systems/ntfs/ntfsdir.c index e222434897..bc3bb5e92f 100644 --- a/src/add-ons/kernel/file_systems/ntfs/ntfsdir.c +++ b/src/add-ons/kernel/file_systems/ntfs/ntfsdir.c @@ -183,7 +183,7 @@ fs_readdir(fs_volume *_vol, fs_vnode *_node, void *_cookie, struct dirent *buf, TRACE("fs_readdir - ENTER (sizeof(buf)=%d, bufsize=%d, num=%d\n", sizeof(buf), bufsize, *num); - if (!ns || !node || !cookie || !num || bufsize < sizeof(buf)) { + if (!ns || !node || !cookie || !num || bufsize < sizeof(*buf)) { result = EINVAL; goto exit; } From 599150a3fc4811bd8e66777cf9f1a4e6c371d947 Mon Sep 17 00:00:00 2001 From: Philippe Saint-Pierre Date: Fri, 20 Jul 2012 18:13:49 -0400 Subject: [PATCH 20/46] CID 701957: opendir() NULL returns weren't accounted for. --- src/tools/rm_attrs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/rm_attrs.cpp b/src/tools/rm_attrs.cpp index 49a696ed45..e25ee9af57 100644 --- a/src/tools/rm_attrs.cpp +++ b/src/tools/rm_attrs.cpp @@ -89,7 +89,7 @@ remove_dir_contents(Path& path, bool force, bool removeAttributes) { // open the dir DIR* dir = opendir(path.GetPath()); - if (dir < 0) { + if (dir == NULL) { fprintf(stderr, "Error: Failed to open dir \"%s\": %s\n", path.GetPath(), strerror(errno)); return; From cb1f2e6525cd8c221a6b4571674d288858a394d4 Mon Sep 17 00:00:00 2001 From: Philippe Saint-Pierre Date: Fri, 20 Jul 2012 18:27:30 -0400 Subject: [PATCH 21/46] Precedence of operators issues Bitwise OR is taking precedence on Conditional operator. CID 701957, CID 602560 --- .../usb_webcam/addons/sonix/SonixCamDevice.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.cpp b/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.cpp index e0f3df6fc4..eb20ace8eb 100644 --- a/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.cpp +++ b/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.cpp @@ -407,8 +407,8 @@ SonixCamDevice::ReadIIC(uint8 address, uint8 *data) if (!Sensor()) return B_NO_INIT; //dprintf(ID "sonix_i2c_write_multi(, %02x, %d, {%02x, %02x, %02x, %02x, %02x})\n", slave, count, d0, d1, d2, d3, d4); - buffer[0] = (1 << 4) | Sensor()->Use400kHz()?0x01:0 - | Sensor()->UseRealIIC()?0x80:0; + buffer[0] = (1 << 4) | (Sensor()->Use400kHz()?0x01:0) + | (Sensor()->UseRealIIC()?0x80:0); buffer[1] = Sensor()->IICWriteAddress(); buffer[2] = address; buffer[7] = 0x10; /* absolutely no idea why V4L2 driver use that value */ @@ -421,8 +421,8 @@ SonixCamDevice::ReadIIC(uint8 address, uint8 *data) //dprintf(ID "sonix_i2c_write_multi(, %02x, %d, {%02x, %02x, %02x, %02x, %02x})\n", slave, count, d0, d1, d2, d3, d4); - buffer[0] = (1 << 4) | Sensor()->Use400kHz()?0x01:0 - | 0x02 | Sensor()->UseRealIIC()?0x80:0; /* read 1 byte */ + buffer[0] = (1 << 4) | (Sensor()->Use400kHz()?0x01:0) + | 0x02 | (Sensor()->UseRealIIC()?0x80:0); /* read 1 byte */ buffer[1] = Sensor()->IICReadAddress();//IICWriteAddress buffer[7] = 0x10; /* absolutely no idea why V4L2 driver use that value */ err = WriteReg(SN9C102_I2C_SETUP, buffer, 8); From 902a98ad8340bbbef72bf98b6096ed091abf08f1 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Fri, 20 Jul 2012 19:32:04 -0400 Subject: [PATCH 22/46] Fix #8753. - Store whether or not the use of the horizontal scrollbar is desired on the class itself. If the CLV was set to use the horizontal scrollbar, and then asked to lay itself out while hidden, it would incorrectly assume the horizontal scrollbar wasn't in use, and consequently repositioned its views such that the horizontal scrollbar and outline view overlapped. --- headers/private/interface/ColumnListView.h | 4 +-- src/kits/interface/ColumnListView.cpp | 35 +++++++++++----------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/headers/private/interface/ColumnListView.h b/headers/private/interface/ColumnListView.h index 33773acd8e..2acbbdbb6c 100644 --- a/headers/private/interface/ColumnListView.h +++ b/headers/private/interface/ColumnListView.h @@ -385,9 +385,8 @@ protected: virtual void DoLayout(); private: - void _Init(bool showHorizontalScrollbar); + void _Init(); void _GetChildViewRects(const BRect& bounds, - bool showHorizontalScrollBar, BRect& titleRect, BRect& outlineRect, BRect& vScrollBarRect, BRect& hScrollBarRect); @@ -404,6 +403,7 @@ private: bool fSortingEnabled; float fLatchWidth; border_style fBorderStyle; + bool fShowingHorizontalScrollBar; }; #endif // _COLUMN_LIST_VIEW_H diff --git a/src/kits/interface/ColumnListView.cpp b/src/kits/interface/ColumnListView.cpp index b31cf0c0a4..c89e77284c 100644 --- a/src/kits/interface/ColumnListView.cpp +++ b/src/kits/interface/ColumnListView.cpp @@ -728,9 +728,10 @@ BColumnListView::BColumnListView(BRect rect, const char* name, fSelectionMessage(NULL), fSortingEnabled(true), fLatchWidth(kLatchWidth), - fBorderStyle(border) + fBorderStyle(border), + fShowingHorizontalScrollBar(showHorizontalScrollbar) { - _Init(showHorizontalScrollbar); + _Init(); } @@ -742,9 +743,10 @@ BColumnListView::BColumnListView(const char* name, uint32 flags, fSelectionMessage(NULL), fSortingEnabled(true), fLatchWidth(kLatchWidth), - fBorderStyle(border) + fBorderStyle(border), + fShowingHorizontalScrollBar(showHorizontalScrollbar) { - _Init(showHorizontalScrollbar); + _Init(); } @@ -1857,8 +1859,8 @@ BColumnListView::PreferredSize() BRect outlineRect; BRect vScrollBarRect; BRect hScrollBarRect; - _GetChildViewRects(Bounds(), !fHorizontalScrollBar->IsHidden(), - titleRect, outlineRect, vScrollBarRect, hScrollBarRect); + _GetChildViewRects(Bounds(), titleRect, outlineRect, vScrollBarRect, + hScrollBarRect); // Start with the extra width for border and scrollbars etc. size.width = titleRect.left - Bounds().left; size.width += Bounds().right - titleRect.right; @@ -1901,8 +1903,8 @@ BColumnListView::DoLayout() BRect outlineRect; BRect vScrollBarRect; BRect hScrollBarRect; - _GetChildViewRects(Bounds(), !fHorizontalScrollBar->IsHidden(), - titleRect, outlineRect, vScrollBarRect, hScrollBarRect); + _GetChildViewRects(Bounds(), titleRect, outlineRect, vScrollBarRect, + hScrollBarRect); fTitleView->MoveTo(titleRect.LeftTop()); fTitleView->ResizeTo(titleRect.Width(), titleRect.Height()); @@ -1923,7 +1925,7 @@ BColumnListView::DoLayout() void -BColumnListView::_Init(bool showHorizontalScrollbar) +BColumnListView::_Init() { SetViewColor(B_TRANSPARENT_32_BIT); @@ -1940,8 +1942,8 @@ BColumnListView::_Init(bool showHorizontalScrollbar) BRect outlineRect; BRect vScrollBarRect; BRect hScrollBarRect; - _GetChildViewRects(bounds, showHorizontalScrollbar, titleRect, outlineRect, - vScrollBarRect, hScrollBarRect); + _GetChildViewRects(bounds, titleRect, outlineRect, vScrollBarRect, + hScrollBarRect); fOutlineView = new OutlineView(outlineRect, &fColumns, &fSortColumns, this); AddChild(fOutlineView); @@ -1959,7 +1961,7 @@ BColumnListView::_Init(bool showHorizontalScrollbar) "horizontal_scroll_bar", fTitleView, 0.0, bounds.Width(), B_HORIZONTAL); AddChild(fHorizontalScrollBar); - if (!showHorizontalScrollbar) + if (!fShowingHorizontalScrollBar) fHorizontalScrollBar->Hide(); fOutlineView->FixScrollBar(true); @@ -1967,9 +1969,8 @@ BColumnListView::_Init(bool showHorizontalScrollbar) void -BColumnListView::_GetChildViewRects(const BRect& bounds, - bool showHorizontalScrollbar, BRect& titleRect, BRect& outlineRect, - BRect& vScrollBarRect, BRect& hScrollBarRect) +BColumnListView::_GetChildViewRects(const BRect& bounds, BRect& titleRect, + BRect& outlineRect, BRect& vScrollBarRect, BRect& hScrollBarRect) { titleRect = bounds; titleRect.bottom = titleRect.top + kTitleHeight; @@ -1980,7 +1981,7 @@ BColumnListView::_GetChildViewRects(const BRect& bounds, outlineRect = bounds; outlineRect.top = titleRect.bottom + 1.0; outlineRect.right -= B_V_SCROLL_BAR_WIDTH; - if (showHorizontalScrollbar) + if (fShowingHorizontalScrollBar) outlineRect.bottom -= B_H_SCROLL_BAR_HEIGHT; vScrollBarRect = bounds; @@ -1989,7 +1990,7 @@ BColumnListView::_GetChildViewRects(const BRect& bounds, #endif vScrollBarRect.left = vScrollBarRect.right - B_V_SCROLL_BAR_WIDTH; - if (showHorizontalScrollbar) + if (fShowingHorizontalScrollBar) vScrollBarRect.bottom -= B_H_SCROLL_BAR_HEIGHT; hScrollBarRect = bounds; From 2d5785ba12f796e972151830a0465b68f3d7e34d Mon Sep 17 00:00:00 2001 From: Philippe Saint-Pierre Date: Fri, 20 Jul 2012 19:41:12 -0400 Subject: [PATCH 23/46] CID 611239: Fix resource leak --- src/kits/media/SoundFile.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/kits/media/SoundFile.cpp b/src/kits/media/SoundFile.cpp index 8a0371673e..7428680f72 100644 --- a/src/kits/media/SoundFile.cpp +++ b/src/kits/media/SoundFile.cpp @@ -361,8 +361,11 @@ BSoundFile::_ref_to_file(const entry_ref *ref) raw = &mf.u.raw_audio; } - if (raw == NULL) + if (raw == NULL) { + delete media; + delete file; return B_ERROR; + } fSamplingRate = (int)raw->frame_rate; fChannelCount = raw->channel_count; From fd2ea9d89306d270d9a16ece3afa0733f29bdaf5 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Fri, 20 Jul 2012 22:38:28 -0400 Subject: [PATCH 24/46] Fix #8737. - Updated haikuwebkit package with fixes for context menus and file downloads from aldeck's github repository. --- build/jam/OptionalBuildFeatures | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/jam/OptionalBuildFeatures b/build/jam/OptionalBuildFeatures index 60d0b71710..ecf27e82ab 100644 --- a/build/jam/OptionalBuildFeatures +++ b/build/jam/OptionalBuildFeatures @@ -435,7 +435,7 @@ if [ IsOptionalHaikuImagePackageAdded WebPositive ] { HAIKU_BUILD_FEATURE_WEBKIT = 1 ; } -HAIKU_WEBKIT_FILE = haikuwebkit-1.1.2-x86-gcc4-2012-07-11.zip ; +HAIKU_WEBKIT_FILE = haikuwebkit-1.1.3-x86-gcc4-2012-07-20.zip ; if $(HAIKU_BUILD_FEATURE_WEBKIT) { if $(TARGET_ARCH) != x86 { From 667fd4d0eaf904b3928d52c740e0bbc7bdc88f86 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Fri, 20 Jul 2012 23:01:23 -0400 Subject: [PATCH 25/46] Update webkit package with one additional bugfix. --- build/jam/OptionalBuildFeatures | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/jam/OptionalBuildFeatures b/build/jam/OptionalBuildFeatures index ecf27e82ab..398a59ea40 100644 --- a/build/jam/OptionalBuildFeatures +++ b/build/jam/OptionalBuildFeatures @@ -435,7 +435,7 @@ if [ IsOptionalHaikuImagePackageAdded WebPositive ] { HAIKU_BUILD_FEATURE_WEBKIT = 1 ; } -HAIKU_WEBKIT_FILE = haikuwebkit-1.1.3-x86-gcc4-2012-07-20.zip ; +HAIKU_WEBKIT_FILE = haikuwebkit-1.1.3-x86-gcc4-2012-07-20-1.zip ; if $(HAIKU_BUILD_FEATURE_WEBKIT) { if $(TARGET_ARCH) != x86 { From 5ba5e31f8a59cb5f3299edd7af256d0fb4db12aa Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Sat, 21 Jul 2012 02:48:40 +0000 Subject: [PATCH 26/46] usb_serial: clean up usb device identification * Update FTDI, KLSI, Prolific, and Silicon drivers to share a common structural layout for device identification. * More flexible and cleaner than massive switch case statements. * Avoids the problem of different chipsets from identical vendors. --- .../kernel/drivers/ports/usb_serial/FTDI.cpp | 11 +- .../kernel/drivers/ports/usb_serial/FTDI.h | 15 +- .../kernel/drivers/ports/usb_serial/KLSI.h | 15 +- .../drivers/ports/usb_serial/Prolific.h | 40 +- .../drivers/ports/usb_serial/SerialDevice.cpp | 485 ++---------------- .../drivers/ports/usb_serial/SerialDevice.h | 12 + .../drivers/ports/usb_serial/Silicon.cpp | 3 + .../kernel/drivers/ports/usb_serial/Silicon.h | 146 +++++- 8 files changed, 235 insertions(+), 492 deletions(-) diff --git a/src/add-ons/kernel/drivers/ports/usb_serial/FTDI.cpp b/src/add-ons/kernel/drivers/ports/usb_serial/FTDI.cpp index 1d77c605c1..649975bbd9 100644 --- a/src/add-ons/kernel/drivers/ports/usb_serial/FTDI.cpp +++ b/src/add-ons/kernel/drivers/ports/usb_serial/FTDI.cpp @@ -4,10 +4,16 @@ * * Copyright (c) 2003 by Siarzhuk Zharski * Distributed under the terms of the MIT License. + * + * Authors: + * Alexander von Gluck IV, kallisti5@unixzen.com */ + + #include "FTDI.h" #include "FTDIRegs.h" + FTDIDevice::FTDIDevice(usb_device device, uint16 vendorID, uint16 productID, const char *description) : SerialDevice(device, vendorID, productID, description), @@ -46,7 +52,7 @@ FTDIDevice::AddDevice(const usb_configuration_info *config) } if (pipesSet >= 3) { - if (ProductID() == PRODUCT_FTDI_8U100AX) + if (ProductID() == 0x8372) // AU100AX fHeaderLength = 1; else fHeaderLength = 0; @@ -84,7 +90,8 @@ FTDIDevice::SetLineCoding(usb_cdc_line_coding *lineCoding) lineCoding->databits); int32 rate = 0; - if (ProductID() == PRODUCT_FTDI_8U100AX) { + if (ProductID() == 0x8372) { + // AU100AX switch (lineCoding->speed) { case 300: rate = ftdi_sio_b300; break; case 600: rate = ftdi_sio_b600; break; diff --git a/src/add-ons/kernel/drivers/ports/usb_serial/FTDI.h b/src/add-ons/kernel/drivers/ports/usb_serial/FTDI.h index 05b7cb2a3d..7e32721aed 100644 --- a/src/add-ons/kernel/drivers/ports/usb_serial/FTDI.h +++ b/src/add-ons/kernel/drivers/ports/usb_serial/FTDI.h @@ -4,16 +4,24 @@ * * Copyright (c) 2003 by Siarzhuk Zharski * Distributed under the terms of the MIT License. + * + * Authors: + * Alexander von Gluck IV, kallisti5@unixzen.com */ #ifndef _USB_FTDI_H_ #define _USB_FTDI_H_ + #include "SerialDevice.h" + /* supported vendor and product ids */ -#define VENDOR_FTDI 0x0403 -#define PRODUCT_FTDI_8U100AX 0x8372 -#define PRODUCT_FTDI_8U232AM 0x6001 +#define VENDOR_FTDI 0x0403 + +const usb_serial_device kFTDIDevices[] = { + {VENDOR_FTDI, 0x8372, "FTDI 8U100AX serial converter"}, + {VENDOR_FTDI, 0x6001, "FTDI 8U232AM serial converter"} +}; #define FTDI_BUFFER_SIZE 64 @@ -40,4 +48,5 @@ private: uint8 fStatusLSR; }; + #endif //_USB_FTDI_H_ diff --git a/src/add-ons/kernel/drivers/ports/usb_serial/KLSI.h b/src/add-ons/kernel/drivers/ports/usb_serial/KLSI.h index bc2dce506f..52e1e78700 100644 --- a/src/add-ons/kernel/drivers/ports/usb_serial/KLSI.h +++ b/src/add-ons/kernel/drivers/ports/usb_serial/KLSI.h @@ -8,13 +8,19 @@ #ifndef _USB_KLSI_H_ #define _USB_KLSI_H_ + #include "SerialDevice.h" + /* supported vendor and product ids */ -#define VENDOR_PALM 0x0830 -#define VENDOR_KLSI 0x05e9 -#define PRODUCT_PALM_CONNECT 0x0080 -#define PRODUCT_KLSI_KL5KUSB105D 0x00c0 +#define VENDOR_PALM 0x0830 +#define VENDOR_KLSI 0x05e9 + +const usb_serial_device kKLSIDevices[] = { + {VENDOR_PALM, 0x0080, "PalmConnect RS232"}, + {VENDOR_KLSI, 0x00c0, "KLSI KL5KUSB105D"} +}; + /* protocol defines */ #define KLSI_SET_REQUEST 0x01 @@ -58,4 +64,5 @@ virtual void OnWrite(const char *buffer, size_t *numBytes, virtual void OnClose(); }; + #endif //_USB_KLSI_H_ diff --git a/src/add-ons/kernel/drivers/ports/usb_serial/Prolific.h b/src/add-ons/kernel/drivers/ports/usb_serial/Prolific.h index 81e6de0843..acae2541f4 100644 --- a/src/add-ons/kernel/drivers/ports/usb_serial/Prolific.h +++ b/src/add-ons/kernel/drivers/ports/usb_serial/Prolific.h @@ -4,36 +4,43 @@ * * Copyright (c) 2003-2004 by Siarzhuk Zharski * Distributed under the terms of the MIT License. + * + * Authors: + * Alexander von Gluck IV, kallisti5@unixzen.com */ #ifndef _USB_PROLIFIC_H_ #define _USB_PROLIFIC_H_ + #include "ACM.h" + /* supported vendor and product ids */ #define VENDOR_PROLIFIC 0x067b -#define VENDOR_IODATA 0x04bb #define VENDOR_ATEN 0x0557 -#define VENDOR_TDK 0x04bf -#define VENDOR_RATOC 0x0584 #define VENDOR_ELECOM 0x056e -#define VENDOR_SOURCENEXT 0x0833 -#define VENDOR_HAL 0x0b41 +#define VENDOR_HAL 0x0b41 +#define VENDOR_IODATA 0x04bb +#define VENDOR_RATOC 0x0584 +#define VENDOR_SOURCENEXT 0x0833 +#define VENDOR_TDK 0x04bf + +const usb_serial_device kProlificDevices[] = { + {VENDOR_PROLIFIC, 0x04bb, "PL2303 Serial adapter (IODATA USB-RSAQ2)"}, + {VENDOR_PROLIFIC, 0x2303, "PL2303 Serial adapter (ATEN/IOGEAR UC232A)"}, + {VENDOR_ATEN, 0x2008, "Aten Serial adapter"}, + {VENDOR_ELECOM, 0x5003, "Elecom UC-SGT"}, + {VENDOR_HAL, 0x0011, "HAL Corporation Crossam2+USB"}, + {VENDOR_IODATA, 0x0a03, "I/O Data USB serial adapter USB-RSAQ1"}, + {VENDOR_RATOC, 0xb000, "Ratoc USB serial adapter REX-USB60"}, + {VENDOR_SOURCENEXT, 0x039f, "SOURCENEXT KeikaiDenwa 8"}, + {VENDOR_SOURCENEXT, 0x039f, "SOURCENEXT KeikaiDenwa 8 with charger"}, + {VENDOR_TDK, 0x0117, "TDK USB-PHS Adapter UHA6400"} +}; -#define PRODUCT_IODATA_USBRSAQ 0x0a03 -#define PRODUCT_PROLIFIC_RSAQ2 0x04bb -#define PRODUCT_ATEN_UC232A 0x2008 -#define PRODUCT_PROLIFIC_PL2303 0x2303 -#define PRODUCT_TDK_UHA6400 0x0117 -#define PRODUCT_RATOC_REXUSB60 0xb000 -#define PRODUCT_ELECOM_UCSGT 0x5003 -#define PRODUCT_SOURCENEXT_KEIKAI8 0x039f -#define PRODUCT_SOURCENEXT_KEIKAI8_CHG 0x012e -#define PRODUCT_HAL_IMR001 0x0011 /* protocol defines */ #define PROLIFIC_SET_REQUEST 0x01 - #define PROLIFIC_BUF_SIZE 256 struct request_item; @@ -55,4 +62,5 @@ private: bool fIsHX; }; + #endif //_USB_PROLIFIC_H_ diff --git a/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.cpp b/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.cpp index 0d76a31550..2d8e62e528 100644 --- a/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.cpp +++ b/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.cpp @@ -4,7 +4,12 @@ * * Copyright (c) 2003 by Siarzhuk Zharski * Distributed under the terms of the MIT License. + * + * Authors: + * Alexander von Gluck IV, kallisti5@unixzen.com */ + + #include #include "SerialDevice.h" @@ -714,451 +719,47 @@ SerialDevice * SerialDevice::MakeDevice(usb_device device, uint16 vendorID, uint16 productID) { - const char *description = NULL; - - switch (vendorID) { - case VENDOR_IODATA: - case VENDOR_ATEN: - case VENDOR_TDK: - case VENDOR_RATOC: - case VENDOR_PROLIFIC: - case VENDOR_ELECOM: - case VENDOR_SOURCENEXT: - case VENDOR_HAL: - { - switch (productID) { - case PRODUCT_PROLIFIC_RSAQ2: - description = "PL2303 Serial adapter (IODATA USB-RSAQ2)"; - break; - case PRODUCT_IODATA_USBRSAQ: - description = "I/O Data USB serial adapter USB-RSAQ1"; - break; - case PRODUCT_ATEN_UC232A: - description = "Aten Serial adapter"; - break; - case PRODUCT_TDK_UHA6400: - description = "TDK USB-PHS Adapter UHA6400"; - break; - case PRODUCT_RATOC_REXUSB60: - description = "Ratoc USB serial adapter REX-USB60"; - break; - case PRODUCT_PROLIFIC_PL2303: - description = "PL2303 Serial adapter (ATEN/IOGEAR UC232A)"; - break; - case PRODUCT_ELECOM_UCSGT: - description = "Elecom UC-SGT"; - break; - case PRODUCT_SOURCENEXT_KEIKAI8: - description = "SOURCENEXT KeikaiDenwa 8"; - break; - case PRODUCT_SOURCENEXT_KEIKAI8_CHG: - description = "SOURCENEXT KeikaiDenwa 8 with charger"; - break; - case PRODUCT_HAL_IMR001: - description = "HAL Corporation Crossam2+USB"; - break; - } - - if (description == NULL) - break; - - return new(std::nothrow) ProlificDevice(device, vendorID, productID, - description); + // FTDI Serial Device + for (uint32 i = 0; i < sizeof(kFTDIDevices) + / sizeof(kFTDIDevices[0]); i++) { + if (vendorID == kFTDIDevices[i].vendorID + && productID == kFTDIDevices[i].productID) { + return new(std::nothrow) FTDIDevice(device, vendorID, productID, + kFTDIDevices[i].deviceName); } - - case VENDOR_FTDI: - { - switch (productID) { - case PRODUCT_FTDI_8U100AX: - description = "FTDI 8U100AX serial converter"; - break; - case PRODUCT_FTDI_8U232AM: - description = "FTDI 8U232AM serial converter"; - break; - } - - if (description == NULL) - break; - - return new(std::nothrow) FTDIDevice(device, vendorID, productID, - description); - } - - case VENDOR_PALM: - case VENDOR_KLSI: - { - switch (productID) { - case PRODUCT_PALM_CONNECT: - description = "PalmConnect RS232"; - break; - case PRODUCT_KLSI_KL5KUSB105D: - description = "KLSI KL5KUSB105D"; - break; - } - - if (description == NULL) - break; - - return new(std::nothrow) KLSIDevice(device, vendorID, productID, - description); - } - - case VENDOR_RENESAS: - { - switch (productID) { - case 0x0053: - description = "Renesas RX610 RX-Stick"; - break; - } - - if (description != NULL) - goto SILICON; - break; - } - case VENDOR_AKATOM: - { - switch (productID) { - case 0x066A: - description = "AKTAKOM ACE-1001"; - break; - } - - if (description != NULL) - goto SILICON; - break; - } - case VENDOR_PIRELLI: - { - switch (productID) { - case 0xE000: - case 0xE003: - description = "Pirelli DP-L10 GSM Mobile"; - break; - } - - if (description != NULL) - goto SILICON; - break; - } - case VENDOR_CYPHERLAB: - { - switch (productID) { - case 0x1000: - description = "Cipherlab CCD Barcode Scanner"; - break; - } - - if (description != NULL) - goto SILICON; - break; - } - case VENDOR_GEMALTO: - { - switch (productID) { - case 0x5501: - description = "Gemalto contactless smartcard reader"; - break; - } - - if (description != NULL) - goto SILICON; - break; - } - case VENDOR_DIGIANSWER: - { - switch (productID) { - case 0x000A: - description = "Digianswer ZigBee MAC device"; - break; - } - - if (description != NULL) - goto SILICON; - break; - } - case VENDOR_MEI: - { - switch (productID) { - case 0x1100: - case 0x1101: - description = "MEI Acceptor"; - break; - } - - if (description != NULL) - goto SILICON; - break; - } - case VENDOR_DYNASTREAM: - { - switch (productID) { - case 0x1003: - case 0x1004: - case 0x1006: - description = "Dynastream ANT development board"; - break; - } - - if (description != NULL) - goto SILICON; - break; - } - case VENDOR_KNOCKOFF: - { - switch (productID) { - case 0xAA26: - description = "Knock-off DCU-11"; - break; - } - - if (description != NULL) - goto SILICON; - break; - } - case VENDOR_SIEMENS: - { - switch (productID) { - case 0x10C5: - description = "Siemens MC60"; - break; - } - - if (description != NULL) - goto SILICON; - break; - } - case VENDOR_NOKIA: - { - switch (productID) { - case 0xAC70: - description = "Nokia CA-42"; - break; - } - - if (description != NULL) - goto SILICON; - break; - } - case VENDOR_SILICON: - { - switch (productID) { - case 0x0F91: - case 0x1101: - case 0x1601: - case 0x800A: - case 0x803B: - case 0x8044: - case 0x804E: - case 0x8053: - case 0x8054: - case 0x8066: - case 0x806F: - case 0x807A: - case 0x80CA: - case 0x80DD: - case 0x80F6: - case 0x8115: - case 0x813D: - case 0x813F: - case 0x814A: - case 0x814B: - case 0x8156: - case 0x815E: - case 0x818B: - case 0x819F: - case 0x81A6: - case 0x81AC: - case 0x81AD: - case 0x81C8: - case 0x81E2: - case 0x81E7: - case 0x81E8: - case 0x81F2: - case 0x8218: - case 0x822B: - case 0x826B: - case 0x8293: - case 0x82F9: - case 0x8341: - case 0x8382: - case 0x83A8: - case 0x83D8: - case 0x8411: - case 0x8418: - case 0x846E: - case 0x8477: - case 0x85EA: - case 0x85EB: - case 0x8664: - case 0x8665: - case 0xEA60: - case 0xEA61: - case 0xEA71: - case 0xF001: - case 0xF002: - case 0xF003: - case 0xF004: - description = "Silicon Labs CP210x USB UART converter"; - break; - } - - if (description != NULL) - goto SILICON; - break; - } - case VENDOR_SILICON2: - { - switch (productID) { - case 0xEA61: - description = "Silicon Labs GPRS USB Modem"; - break; - } - - if (description != NULL) - goto SILICON; - break; - } - case VENDOR_SILICON3: - { - switch (productID) { - case 0xEA6A: - description = "Silicon Labs GPRS USB Modem 100EU"; - break; - } - - if (description != NULL) - goto SILICON; - break; - } - case VENDOR_BALTECH: - { - switch (productID) { - case 0x9999: - description = "Balteck card reader"; - break; - } - - if (description != NULL) - goto SILICON; - break; - } - case VENDOR_OWEN: - { - switch (productID) { - case 0x0004: - description = "Owen AC4 USB-RS485 Converter"; - break; - } - - if (description != NULL) - goto SILICON; - break; - } - case VENDOR_CLIPSAL: - { - switch (productID) { - case 0x0303: - description = "Clipsal 5500PCU C-Bus USB interface"; - break; - } - - if (description != NULL) - goto SILICON; - break; - } - case VENDOR_JABLOTRON: - { - switch (productID) { - case 0x0001: - description = "Jablotron serial interface"; - break; - } - - if (description != NULL) - goto SILICON; - break; - } - case VENDOR_WIENER: - { - switch (productID) { - case 0x0010: - case 0x0011: - case 0x0012: - case 0x0015: - description = "W-IE-NE-R Plein & Baus GmbH device"; - break; - } - - if (description != NULL) - goto SILICON; - break; - } - case VENDOR_WAVESENSE: - { - switch (productID) { - case 0xAAAA: - description = "Wavesense Jazz blood glucose meter"; - break; - } - - if (description != NULL) - goto SILICON; - break; - } - case VENDOR_VAISALA: - { - switch (productID) { - case 0x0200: - description = "Vaisala USB instrument"; - break; - } - - if (description != NULL) - goto SILICON; - break; - } - case VENDOR_ELV: - { - switch (productID) { - case 0xE00F: - description = "ELV USB I²C interface"; - break; - } - - if (description != NULL) - goto SILICON; - break; - } - case VENDOR_WAGO: - { - switch (productID) { - case 0x07A6: - description = "WAGO 750-923 USB Service"; - break; - } - - if (description != NULL) - goto SILICON; - break; - } - case VENDOR_DW700: - { - switch (productID) { - case 0x9500: - description = "DW700 GPS USB interface"; - break; - } - - if (description != NULL) - goto SILICON; - break; - } - -SILICON: - return new(std::nothrow) SiliconDevice(device, vendorID, productID, - description); } + // KLSI Serial Device + for (uint32 i = 0; i < sizeof(kKLSIDevices) + / sizeof(kKLSIDevices[0]); i++) { + if (vendorID == kKLSIDevices[i].vendorID + && productID == kKLSIDevices[i].productID) { + return new(std::nothrow) KLSIDevice(device, vendorID, productID, + kKLSIDevices[i].deviceName); + } + } + + // Prolific Serial Device + for (uint32 i = 0; i < sizeof(kProlificDevices) + / sizeof(kProlificDevices[0]); i++) { + if (vendorID == kProlificDevices[i].vendorID + && productID == kProlificDevices[i].productID) { + return new(std::nothrow) ProlificDevice(device, vendorID, productID, + kProlificDevices[i].deviceName); + } + } + + // Silicon Serial Device + for (uint32 i = 0; i < sizeof(kSiliconDevices) + / sizeof(kSiliconDevices[0]); i++) { + if (vendorID == kSiliconDevices[i].vendorID + && productID == kSiliconDevices[i].productID) { + return new(std::nothrow) SiliconDevice(device, vendorID, productID, + kSiliconDevices[i].deviceName); + } + } + + // Otherwise, return standard ACM device return new(std::nothrow) ACMDevice(device, vendorID, productID, "CDC ACM compatible device"); } diff --git a/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.h b/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.h index e27ecddb7a..57afc10cb7 100644 --- a/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.h +++ b/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.h @@ -4,12 +4,24 @@ * * Copyright (c) 2003 by Siarzhuk Zharski * Distributed under the terms of the MIT License. + * + * Authors: + * Alexander von Gluck IV, kallisti5@unixzen.com */ #ifndef _USB_DEVICE_H_ #define _USB_DEVICE_H_ + #include "Driver.h" + +struct usb_serial_device { + uint32 vendorID; + uint32 productID; + const char* deviceName; +}; + + class SerialDevice { public: SerialDevice(usb_device device, diff --git a/src/add-ons/kernel/drivers/ports/usb_serial/Silicon.cpp b/src/add-ons/kernel/drivers/ports/usb_serial/Silicon.cpp index 5f3a33e451..f902302f98 100644 --- a/src/add-ons/kernel/drivers/ports/usb_serial/Silicon.cpp +++ b/src/add-ons/kernel/drivers/ports/usb_serial/Silicon.cpp @@ -1,6 +1,9 @@ /* * Copyright 2011, Adrien Destugues * Distributed under the terms of the MIT License. + * + * Authors: + * Alexander von Gluck IV, kallisti5@unixzen.com */ diff --git a/src/add-ons/kernel/drivers/ports/usb_serial/Silicon.h b/src/add-ons/kernel/drivers/ports/usb_serial/Silicon.h index 3c1897dac4..e12916b94b 100644 --- a/src/add-ons/kernel/drivers/ports/usb_serial/Silicon.h +++ b/src/add-ons/kernel/drivers/ports/usb_serial/Silicon.h @@ -1,12 +1,133 @@ /* * Copyright 2011, Adrien Destugues * Distributed under the terms of the MIT License. + * + * Authors: + * Alexander von Gluck IV, kallisti5@unixzen.com */ #ifndef _USB_SILICON_H_ #define _USB_SILICON_H_ + #include "SerialDevice.h" + +/* supported vendor and product ids */ +#define VENDOR_RENESAS 0x045B +#define VENDOR_AKATOM 0x0471 +#define VENDOR_PIRELLI 0x0489 +#define VENDOR_CYPHERLAB 0x0745 +#define VENDOR_GEMALTO 0x08E6 +#define VENDOR_DIGIANSWER 0x08FD +#define VENDOR_MEI 0x0BED +#define VENDOR_DYNASTREAM 0x0FCF +#define VENDOR_KNOCKOFF 0x10A6 +#define VENDOR_SIEMENS 0x10AB +#define VENDOR_NOKIA 0x10B5 +#define VENDOR_SILICON 0x10C4 +#define VENDOR_SILICON2 0x10C5 +#define VENDOR_SILICON3 0x10CE +#define VENDOR_BALTECH 0x13AD +#define VENDOR_OWEN 0x1555 +#define VENDOR_CLIPSAL 0x166A +#define VENDOR_JABLOTRON 0x16D6 +#define VENDOR_WIENER 0x16DC +#define VENDOR_WAVESENSE 0x17F4 +#define VENDOR_VAISALA 0x1843 +#define VENDOR_ELV 0x18EF +#define VENDOR_WAGO 0x1BE3 +#define VENDOR_DW700 0x413C + +const usb_serial_device kSiliconDevices[] = { + {VENDOR_RENESAS, 0x0053, "Renesas RX610 RX-Stick"}, + {VENDOR_AKATOM, 0x066A, "AKTAKOM ACE-1001"}, + {VENDOR_PIRELLI, 0xE000, "Pirelli DP-L10 GSM Mobile"}, + {VENDOR_PIRELLI, 0xE003, "Pirelli DP-L10 GSM Mobile"}, + {VENDOR_CYPHERLAB, 0x1000, "Cipherlab CCD Barcode Scanner"}, + {VENDOR_GEMALTO, 0x5501, "Gemalto contactless smartcard reader"}, + {VENDOR_DIGIANSWER, 0x000A, "Digianswer ZigBee MAC device"}, + {VENDOR_MEI, 0x1100, "MEI Acceptor"}, + {VENDOR_MEI, 0x1101, "MEI Acceptor"}, + {VENDOR_DYNASTREAM, 0x1003, "Dynastream ANT development board"}, + {VENDOR_DYNASTREAM, 0x1004, "Dynastream ANT development board"}, + {VENDOR_DYNASTREAM, 0x1006, "Dynastream ANT development board"}, + {VENDOR_KNOCKOFF, 0xAA26, "Knock-off DCU-11"}, + {VENDOR_SIEMENS, 0x10C5, "Siemens MC60"}, + {VENDOR_NOKIA, 0xAC70, "Nokia CA-42"}, + {VENDOR_BALTECH, 0x9999, "Balteck card reader"}, + {VENDOR_OWEN, 0x0004, "Owen AC4 USB-RS485 Converter"}, + {VENDOR_CLIPSAL, 0x0303, "Clipsal 5500PCU C-Bus USB interface"}, + {VENDOR_JABLOTRON, 0x0001, "Jablotron serial interface"}, + {VENDOR_WIENER, 0x0010, "W-IE-NE-R Plein & Baus GmbH device"}, + {VENDOR_WIENER, 0x0011, "W-IE-NE-R Plein & Baus GmbH device"}, + {VENDOR_WIENER, 0x0012, "W-IE-NE-R Plein & Baus GmbH device"}, + {VENDOR_WIENER, 0x0015, "W-IE-NE-R Plein & Baus GmbH device"}, + {VENDOR_WAVESENSE, 0xAAAA, "Wavesense Jazz blood glucose meter"}, + {VENDOR_VAISALA, 0x0200, "Vaisala USB instrument"}, + {VENDOR_ELV, 0xE00F, "ELV USB I²C interface"}, + {VENDOR_WAGO, 0x07A6, "WAGO 750-923 USB Service"}, + {VENDOR_DW700, 0x9500, "DW700 GPS USB interface"}, + {VENDOR_SILICON, 0x0F91, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x1101, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x1601, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x800A, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x803B, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x8044, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x804E, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x8053, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x8054, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x8066, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x806F, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x807A, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x80CA, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x80DD, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x80F6, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x8115, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x813D, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x813F, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x814A, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x814B, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x8156, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x815E, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x818B, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x819F, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x81A6, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x81AC, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x81AD, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x81C8, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x81E2, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x81E7, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x81E8, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x81F2, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x8218, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x822B, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x826B, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x8293, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x82F9, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x8341, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x8382, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x83A8, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x83D8, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x8411, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x8418, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x846E, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x8477, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x85EA, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x85EB, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x8664, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0x8665, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0xEA60, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0xEA61, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0xEA71, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0xF001, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0xF002, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0xF003, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON, 0xF004, "Silicon Labs CP210x USB UART converter"}, + {VENDOR_SILICON2, 0xEA61, "Silicon Labs GPRS USB Modem"}, + {VENDOR_SILICON3, 0xEA6A, "Silicon Labs GPRS USB Modem 100EU"} +}; + + class SiliconDevice : public SerialDevice { public: SiliconDevice(usb_device device, uint16 vendorID, @@ -98,30 +219,5 @@ status_t WriteConfig(CP210XRequest request, uint16_t* data, size_t size); }; -#define VENDOR_RENESAS 0x045B -#define VENDOR_AKATOM 0x0471 -#define VENDOR_PIRELLI 0x0489 -#define VENDOR_CYPHERLAB 0x0745 -#define VENDOR_GEMALTO 0x08E6 -#define VENDOR_DIGIANSWER 0x08FD -#define VENDOR_MEI 0x0BED -#define VENDOR_DYNASTREAM 0x0FCF -#define VENDOR_KNOCKOFF 0x10A6 -#define VENDOR_SIEMENS 0x10AB -#define VENDOR_NOKIA 0x10B5 -#define VENDOR_SILICON 0x10C4 -#define VENDOR_SILICON2 0x10C5 -#define VENDOR_SILICON3 0x10CE -#define VENDOR_BALTECH 0x13AD -#define VENDOR_OWEN 0x1555 -#define VENDOR_CLIPSAL 0x166A -#define VENDOR_JABLOTRON 0x16D6 -#define VENDOR_WIENER 0x16DC -#define VENDOR_WAVESENSE 0x17F4 -#define VENDOR_VAISALA 0x1843 -#define VENDOR_ELV 0x18EF -#define VENDOR_WAGO 0x1BE3 -#define VENDOR_DW700 0x413C - #endif //_USB_SILICON_H_ From 0a592099a94eb3727053c0e2ca571398dff75701 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sat, 21 Jul 2012 09:18:34 +0200 Subject: [PATCH 27/46] Debugger: Rework CLI setup to no longer create a BApplication The main thread does now serve the CLI input loop. --- src/apps/debugger/Debugger.cpp | 259 +++++++++++++----- .../cli/CommandLineUserInterface.cpp | 47 +++- .../cli/CommandLineUserInterface.h | 8 +- 3 files changed, 245 insertions(+), 69 deletions(-) diff --git a/src/apps/debugger/Debugger.cpp b/src/apps/debugger/Debugger.cpp index f5617470aa..bac8ac0d13 100644 --- a/src/apps/debugger/Debugger.cpp +++ b/src/apps/debugger/Debugger.cpp @@ -88,6 +88,13 @@ struct Options { }; +struct DebuggedProgramInfo { + team_id team; + thread_id thread; + bool stopInMain; +}; + + static bool parse_arguments(int argc, const char* const* argv, bool noOutput, Options& options) @@ -174,25 +181,104 @@ parse_arguments(int argc, const char* const* argv, bool noOutput, return true; } +static status_t +global_init() +{ + status_t error = TypeHandlerRoster::CreateDefault(); + if (error != B_OK) + return error; + error = ValueHandlerRoster::CreateDefault(); + if (error != B_OK) + return error; + + return B_OK; +} + + +/** + * Finds or runs the program to debug, depending on the command line options. + * @param options The parsed command line options. + * @param _info The info for the program to fill in. Will only be filled in + * if successful. + * @return \c true, if the program has been found or ran. + */ +static bool +get_debugged_program(const Options& options, DebuggedProgramInfo& _info) +{ + team_id team = options.team; + thread_id thread = options.thread; + bool stopInMain = false; + + // If command line arguments were given, start the program. + if (options.commandLineArgc > 0) { + printf("loading program: \"%s\" ...\n", options.commandLineArgv[0]); + // TODO: What about the CWD? + thread = load_program(options.commandLineArgv, + options.commandLineArgc, false); + if (thread < 0) { + // TODO: Notify the user! + fprintf(stderr, "Error: Failed to load program \"%s\": %s\n", + options.commandLineArgv[0], strerror(thread)); + return false; + } + + team = thread; + // main thread ID == team ID + stopInMain = true; + } + + // no parameters given, prompt the user to attach to a team + if (team < 0 && thread < 0) + return false; + + // no team, but a thread -- get team + if (team < 0) { + printf("no team yet, getting thread info...\n"); + thread_info threadInfo; + status_t error = get_thread_info(thread, &threadInfo); + if (error != B_OK) { + // TODO: Notify the user! + fprintf(stderr, "Error: Failed to get info for thread \"%ld\": " + "%s\n", thread, strerror(error)); + return false; + } + + team = threadInfo.team; + } + printf("team: %ld, thread: %ld\n", team, thread); + + _info.team = team; + _info.thread = thread; + _info.stopInMain = stopInMain; + return true; +} + + +/** + * Creates a TeamDebugger for the given team. If userInterface is given, + * that user interface is used (the caller retains its reference), otherwise + * a graphical user interface is created. + */ static TeamDebugger* start_team_debugger(team_id teamID, SettingsManager* settingsManager, TeamDebugger::Listener* listener, thread_id threadID = -1, - bool stopInMain = false, bool useCLI = false) + bool stopInMain = false, UserInterface* userInterface = NULL) { if (teamID < 0) return NULL; - UserInterface* userInterface = useCLI - ? (UserInterface*)new(std::nothrow) CommandLineUserInterface - : (UserInterface*)new(std::nothrow) GraphicalUserInterface; - + BReference userInterfaceReference; if (userInterface == NULL) { - // TODO: Notify the user! - fprintf(stderr, "Error: Out of memory!\n"); - return NULL; + userInterface = new(std::nothrow) GraphicalUserInterface; + if (userInterface == NULL) { + // TODO: Notify the user! + fprintf(stderr, "Error: Out of memory!\n"); + return NULL; + } + + userInterfaceReference.SetTo(userInterface, true); } - BReference userInterfaceReference(userInterface, true); status_t error = B_NO_MEMORY; @@ -213,6 +299,7 @@ start_team_debugger(team_id teamID, SettingsManager* settingsManager, return debugger; } + // #pragma mark - Debugger application class @@ -247,6 +334,26 @@ private: }; +// #pragma mark - CliDebugger + + +class CliDebugger : private TeamDebugger::Listener { +public: + CliDebugger(); + ~CliDebugger(); + + bool Run(const Options& options); + +private: + // TeamDebugger::Listener + virtual void TeamDebuggerStarted(TeamDebugger* debugger); + virtual void TeamDebuggerQuit(TeamDebugger* debugger); +}; + + +// #pragma mark - Debugger application class + + Debugger::Debugger() : BApplication(kDebuggerSignature), @@ -266,11 +373,7 @@ Debugger::~Debugger() status_t Debugger::Init() { - status_t error = TypeHandlerRoster::CreateDefault(); - if (error != B_OK) - return error; - - error = ValueHandlerRoster::CreateDefault(); + status_t error = global_init(); if (error != B_OK) return error; @@ -348,63 +451,22 @@ Debugger::ArgvReceived(int32 argc, char** argv) return; } - team_id team = options.team; - thread_id thread = options.thread; - bool stopInMain = false; - - // If command line arguments were given, start the program. - if (options.commandLineArgc > 0) { - printf("loading program: \"%s\" ...\n", options.commandLineArgv[0]); - // TODO: What about the CWD? - thread = load_program(options.commandLineArgv, - options.commandLineArgc, false); - if (thread < 0) { - // TODO: Notify the user! - fprintf(stderr, "Error: Failed to load program \"%s\": %s\n", - options.commandLineArgv[0], strerror(thread)); - return; - } - - team = thread; - // main thread ID == team ID - stopInMain = true; - } - - // no parameters given, prompt the user to attach to a team - if (team < 0 && thread < 0) + DebuggedProgramInfo programInfo; + if (!get_debugged_program(options, programInfo)) return; - // If we've got - if (team < 0) { - printf("no team yet, getting thread info...\n"); - thread_info threadInfo; - status_t error = get_thread_info(thread, &threadInfo); - if (error != B_OK) { - // TODO: Notify the user! - fprintf(stderr, "Error: Failed to get info for thread \"%ld\": " - "%s\n", thread, strerror(error)); - return; - } - - team = threadInfo.team; - } - printf("team: %ld, thread: %ld\n", team, thread); - - TeamDebugger* debugger = _FindTeamDebugger(team); + TeamDebugger* debugger = _FindTeamDebugger(programInfo.team); if (debugger != NULL) { - printf("There's already a debugger for team: %ld\n", team); + printf("There's already a debugger for team: %ld\n", programInfo.team); debugger->Activate(); return; } - start_team_debugger(team, &fSettingsManager, this, thread, stopInMain, - options.useCLI); + start_team_debugger(programInfo.team, &fSettingsManager, this, + programInfo.thread, programInfo.stopInMain); } -// TeamDebugger::Listener - - void Debugger::TeamDebuggerStarted(TeamDebugger* debugger) { @@ -480,6 +542,76 @@ Debugger::_FindTeamDebugger(team_id teamID) const } +// #pragma mark - CliDebugger + + +CliDebugger::CliDebugger() +{ +} + + +CliDebugger::~CliDebugger() +{ +} + + +bool +CliDebugger::Run(const Options& options) +{ + // initialize global objects and settings manager + status_t error = global_init(); + if (error != B_OK) { + fprintf(stderr, "Error: Global initialization failed: %s\n", + strerror(error)); + return false; + } + + SettingsManager settingsManager; + error = settingsManager.Init(); + if (error != B_OK) { + fprintf(stderr, "Error: Settings manager initialization failed: " + "%s\n", strerror(error)); + return false; + } + + // create the command line UI + CommandLineUserInterface* userInterface + = new(std::nothrow) CommandLineUserInterface; + if (userInterface == NULL) { + fprintf(stderr, "Error: Out of memory!\n"); + return false; + } + BReference userInterfaceReference(userInterface, true); + + // get/run the program to be debugged and start the team debugger + DebuggedProgramInfo programInfo; + if (!get_debugged_program(options, programInfo)) + return false; + + if (start_team_debugger(programInfo.team, &settingsManager, this, + programInfo.thread, programInfo.stopInMain, userInterface) + == NULL) { + return false; + } + + userInterface->Run(); + + return true; +} + + +void +CliDebugger::TeamDebuggerStarted(TeamDebugger* debugger) +{ +} + + +void +CliDebugger::TeamDebuggerQuit(TeamDebugger* debugger) +{ +} + + // #pragma mark - @@ -495,6 +627,11 @@ main(int argc, const char* const* argv) Options options; parse_arguments(argc, argv, false, options); + if (options.useCLI) { + CliDebugger debugger; + return debugger.Run(options) ? 0 : 1; + } + Debugger app; status_t error = app.Init(); if (error != B_OK) { diff --git a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp index ab53011fb2..09db85f913 100644 --- a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp +++ b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp @@ -96,10 +96,11 @@ private: CommandLineUserInterface::CommandLineUserInterface() : - fThread(-1), fTeam(NULL), fListener(NULL), fCommands(20, true), + fShowSemaphore(-1), + fShown(false), fTerminating(false) { } @@ -107,6 +108,8 @@ CommandLineUserInterface::CommandLineUserInterface() CommandLineUserInterface::~CommandLineUserInterface() { + if (fShowSemaphore >= 0) + delete_sem(fShowSemaphore); } @@ -127,9 +130,9 @@ CommandLineUserInterface::Init(Team* team, UserInterfaceListener* listener) if (error != B_OK) return error; - fThread = spawn_thread(&_InputLoopEntry, "CLI", B_NORMAL_PRIORITY, this); - if (fThread < 0) - return fThread; + fShowSemaphore = create_sem(0, "show CLI"); + if (fShowSemaphore < 0) + return fShowSemaphore; return B_OK; } @@ -138,7 +141,8 @@ CommandLineUserInterface::Init(Team* team, UserInterfaceListener* listener) void CommandLineUserInterface::Show() { - resume_thread(fThread); + fShown = true; + release_sem(fShowSemaphore); } @@ -146,8 +150,18 @@ void CommandLineUserInterface::Terminate() { fTerminating = true; - // TODO: Signal the thread so it wakes up! - wait_for_thread(fThread, NULL); + + if (fShown) { + // TODO: Signal the thread so it wakes up! + + // Wait for input loop to finish. + while (acquire_sem(fShowSemaphore) == B_INTERRUPTED) { + } + } else { + // The main thread will still be blocked in Run(). Unblock it. + delete_sem(fShowSemaphore); + fShowSemaphore = -1; + } } @@ -181,6 +195,25 @@ CommandLineUserInterface::SynchronouslyAskUser(const char* title, } +void +CommandLineUserInterface::Run() +{ + // Wait for the Show() semaphore to be released. + status_t error; + do { + error = acquire_sem(fShowSemaphore); + } while (error == B_INTERRUPTED); + + if (error != B_OK) + return; + + _InputLoop(); + + // Release the Show() semaphore to signal Terminate(). + release_sem(fShowSemaphore); +} + + /*static*/ status_t CommandLineUserInterface::_InputLoopEntry(void* data) { diff --git a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h index b581f36b90..9d0c0714b5 100644 --- a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h +++ b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h @@ -40,6 +40,11 @@ public: const char* message, const char* choice1, const char* choice2, const char* choice3); + void Run(); + // Called by the main thread, when + // everything has been set up. Enters the + // input loop. + private: struct CommandEntry; typedef BObjectList CommandList; @@ -63,10 +68,11 @@ private: void _PrintHelp(); private: - thread_id fThread; Team* fTeam; UserInterfaceListener* fListener; CommandList fCommands; + sem_id fShowSemaphore; + bool fShown; bool fTerminating; }; From e6e6f56ccf702fe4bc09821b8064861a200122a8 Mon Sep 17 00:00:00 2001 From: Alex Smith Date: Sat, 21 Jul 2012 14:09:08 +0100 Subject: [PATCH 28/46] Include compat/sys/kernel.h rather than "kernel.h". Using "kernel.h" was pulling in the private kernel.h header instead, which was causing a build failure on my branch since arch_cpu.h is C++-only there. --- src/libs/compat/freebsd_network/clock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/compat/freebsd_network/clock.c b/src/libs/compat/freebsd_network/clock.c index 91a095429d..fce43ccef2 100644 --- a/src/libs/compat/freebsd_network/clock.c +++ b/src/libs/compat/freebsd_network/clock.c @@ -5,7 +5,8 @@ #include "device.h" -#include "kernel.h" + +#include int ticks; From 6b0362305fa9f8a35ce0f2b7052b4c901d040fe9 Mon Sep 17 00:00:00 2001 From: Philippe Saint-Pierre Date: Sat, 21 Jul 2012 11:13:41 -0400 Subject: [PATCH 29/46] FontDemo: make it multibyte chars compliant (UTF-8) fixes #8146. --- src/apps/fontdemo/FontDemoView.cpp | 11 +++++++++-- src/apps/fontdemo/Jamfile | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/apps/fontdemo/FontDemoView.cpp b/src/apps/fontdemo/FontDemoView.cpp index 1dae1a56ed..077ac6e1c1 100644 --- a/src/apps/fontdemo/FontDemoView.cpp +++ b/src/apps/fontdemo/FontDemoView.cpp @@ -20,6 +20,8 @@ #include #include +#include + #include "messages.h" #undef B_TRANSLATION_CONTEXT @@ -99,7 +101,7 @@ FontDemoView::_DrawView(BView* view) view->SetFont(&fFont, B_FONT_ALL); - const size_t size = strlen(fString); + const size_t size = UTF8CountChars(fString, -1); BRect boundBoxes[size]; if (OutLineLevel()) @@ -137,6 +139,8 @@ FontDemoView::_DrawView(BView* view) fBoxRegion.MakeEmpty(); + char *tmpString = fString; + for (size_t i = 0; i < size; i++) { xCoordArray[i] = 0.0f; yCoordArray[i] = 0.0f; @@ -159,7 +163,10 @@ FontDemoView::_DrawView(BView* view) } else { view->SetHighColor(0, 0, 0); view->SetDrawingMode(fDrawingMode); - view->DrawChar(fString[i], BPoint(xCoordArray[i], yCoordArray[i])); + int32 length = UTF8NextCharLen(tmpString); + view->DrawString(tmpString, length, + BPoint(xCoordArray[i], yCoordArray[i])); + tmpString += length; } if (BoundingBoxes() && !OutLineLevel()) { diff --git a/src/apps/fontdemo/Jamfile b/src/apps/fontdemo/Jamfile index 616621f2b0..a02fa1f33f 100644 --- a/src/apps/fontdemo/Jamfile +++ b/src/apps/fontdemo/Jamfile @@ -2,6 +2,8 @@ SubDir HAIKU_TOP src apps fontdemo ; SetSubDirSupportedPlatformsBeOSCompatible ; +UsePrivateHeaders interface ; + Application FontDemo : ControlView.cpp FontDemo.cpp From c5e8e32acd64dbbf41b67aee6dd7badb66c1ca7b Mon Sep 17 00:00:00 2001 From: Philippe Saint-Pierre Date: Sat, 21 Jul 2012 12:23:18 -0400 Subject: [PATCH 30/46] FontDemo: Cleanup of previous UTF-8 compliancy fix Avoid using the private API, rather use the public BString. Thanks mmlr. --- src/apps/fontdemo/FontDemoView.cpp | 14 ++++++-------- src/apps/fontdemo/Jamfile | 2 -- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/apps/fontdemo/FontDemoView.cpp b/src/apps/fontdemo/FontDemoView.cpp index 077ac6e1c1..5294eca5ff 100644 --- a/src/apps/fontdemo/FontDemoView.cpp +++ b/src/apps/fontdemo/FontDemoView.cpp @@ -19,8 +19,7 @@ #include #include #include - -#include +#include #include "messages.h" @@ -101,7 +100,8 @@ FontDemoView::_DrawView(BView* view) view->SetFont(&fFont, B_FONT_ALL); - const size_t size = UTF8CountChars(fString, -1); + BString tmpString(fString); + const size_t size = tmpString.CountChars(); BRect boundBoxes[size]; if (OutLineLevel()) @@ -138,8 +138,6 @@ FontDemoView::_DrawView(BView* view) // region area instead of the whole view. fBoxRegion.MakeEmpty(); - - char *tmpString = fString; for (size_t i = 0; i < size; i++) { xCoordArray[i] = 0.0f; @@ -163,10 +161,10 @@ FontDemoView::_DrawView(BView* view) } else { view->SetHighColor(0, 0, 0); view->SetDrawingMode(fDrawingMode); - int32 length = UTF8NextCharLen(tmpString); - view->DrawString(tmpString, length, + int32 charLength; + const char* charAt = tmpString.CharAt(i, &charLength); + view->DrawString(charAt, charLength, BPoint(xCoordArray[i], yCoordArray[i])); - tmpString += length; } if (BoundingBoxes() && !OutLineLevel()) { diff --git a/src/apps/fontdemo/Jamfile b/src/apps/fontdemo/Jamfile index a02fa1f33f..616621f2b0 100644 --- a/src/apps/fontdemo/Jamfile +++ b/src/apps/fontdemo/Jamfile @@ -2,8 +2,6 @@ SubDir HAIKU_TOP src apps fontdemo ; SetSubDirSupportedPlatformsBeOSCompatible ; -UsePrivateHeaders interface ; - Application FontDemo : ControlView.cpp FontDemo.cpp From 5cf20610e113bcf3bddddf323fdf348ac283c4be Mon Sep 17 00:00:00 2001 From: Philippe Saint-Pierre Date: Sat, 21 Jul 2012 12:58:05 -0400 Subject: [PATCH 31/46] FontDemo: Further cleanup the strlen was used also in _AddShapes. Widen use of BString. Sorry for the noise! --- src/apps/fontdemo/FontDemoView.cpp | 29 ++++++++++++----------------- src/apps/fontdemo/FontDemoView.h | 9 +++++---- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/apps/fontdemo/FontDemoView.cpp b/src/apps/fontdemo/FontDemoView.cpp index 5294eca5ff..af4205ed3d 100644 --- a/src/apps/fontdemo/FontDemoView.cpp +++ b/src/apps/fontdemo/FontDemoView.cpp @@ -30,7 +30,6 @@ FontDemoView::FontDemoView(BRect rect) : BView(rect, "FontDemoView", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS), fBitmap(NULL), fBufferView(NULL), - fString(NULL), fFontSize(50.0), fSpacing(0.0), fOutLineLevel(0), @@ -51,7 +50,6 @@ FontDemoView::FontDemoView(BRect rect) FontDemoView::~FontDemoView() { - free(fString); free(fShapes); fBitmap->Lock(); @@ -100,8 +98,7 @@ FontDemoView::_DrawView(BView* view) view->SetFont(&fFont, B_FONT_ALL); - BString tmpString(fString); - const size_t size = tmpString.CountChars(); + const size_t size = fString.CountChars(); BRect boundBoxes[size]; if (OutLineLevel()) @@ -118,8 +115,8 @@ FontDemoView::_DrawView(BView* view) escapeDeltas[j].space = 0.0f; } */ - fFont.GetEdges(fString, size, edgeInfo); - fFont.GetEscapements(fString, size, /*escapeDeltas,*/ escapementArray); + fFont.GetEdges(fString.String(), size, edgeInfo); + fFont.GetEscapements(fString.String(), size, /*escapeDeltas,*/ escapementArray); font_height fh; fFont.GetHeight(&fh); @@ -162,7 +159,7 @@ FontDemoView::_DrawView(BView* view) view->SetHighColor(0, 0, 0); view->SetDrawingMode(fDrawingMode); int32 charLength; - const char* charAt = tmpString.CharAt(i, &charLength); + const char* charAt = fString.CharAt(i, &charLength); view->DrawString(charAt, charLength, BPoint(xCoordArray[i], yCoordArray[i])); } @@ -192,7 +189,7 @@ FontDemoView::MessageReceived(BMessage* msg) switch (msg->what) { case TEXT_CHANGED_MSG: { - const char* text = NULL; + BString text; if (msg->FindString("_text", &text) == B_OK) { SetString(text); Invalidate(/*&fBoxRegion*/); @@ -358,16 +355,15 @@ FontDemoView::MessageReceived(BMessage* msg) void -FontDemoView::SetString(const char* string) +FontDemoView::SetString(BString string) { - free(fString); - fString = strdup(string); + fString = string; free(fShapes); _AddShapes(fString); } -const char* +BString FontDemoView::String() const { return fString; @@ -424,10 +420,10 @@ FontDemoView::SetOutlineLevel(int8 outline) void -FontDemoView::_AddShapes(const char* string) +FontDemoView::_AddShapes(BString string) { - const size_t size = strlen(string); - fShapes = (BShape**)malloc(sizeof(BShape*)*size); + const size_t size = string.CountChars(); + fShapes = (BShape**)malloc(sizeof(BShape*) * size); for (size_t i = 0; i < size; i++) { fShapes[i] = new BShape(); @@ -460,5 +456,4 @@ FontDemoView::_NewBitmap(BRect rect) delete fBitmap; fBitmap = NULL; } -} - +} \ No newline at end of file diff --git a/src/apps/fontdemo/FontDemoView.h b/src/apps/fontdemo/FontDemoView.h index 66d3daca9e..23b1395eff 100644 --- a/src/apps/fontdemo/FontDemoView.h +++ b/src/apps/fontdemo/FontDemoView.h @@ -11,6 +11,7 @@ #include #include +#include class BShape; class BBitmap; @@ -37,8 +38,8 @@ class FontDemoView : public BView { void SetFontRotation(float rotation); const float Rotation() const { return fFont.Rotation(); } - void SetString(const char* string); - const char* String() const; + void SetString(BString string); + BString String() const; void SetAntialiasing(bool state); @@ -49,7 +50,7 @@ class FontDemoView : public BView { const int8 OutLineLevel() const { return fOutLineLevel; } private: - void _AddShapes(const char* string); + void _AddShapes(BString string); void _DrawView(BView* view); BView* _GetView(BRect rect); @@ -58,7 +59,7 @@ class FontDemoView : public BView { BBitmap* fBitmap; BView* fBufferView; - char* fString; + BString fString; float fFontSize; float fSpacing; int8 fOutLineLevel; From 7050e3cd84cbf0bfdbe4aee9406a9c7240de6e5c Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sat, 21 Jul 2012 19:27:06 +0200 Subject: [PATCH 32/46] Fix wrong assignment. CID 702303. --- src/apps/mediaplayer/interface/SubtitleBitmap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apps/mediaplayer/interface/SubtitleBitmap.cpp b/src/apps/mediaplayer/interface/SubtitleBitmap.cpp index 4d9af3998d..839af6896d 100644 --- a/src/apps/mediaplayer/interface/SubtitleBitmap.cpp +++ b/src/apps/mediaplayer/interface/SubtitleBitmap.cpp @@ -316,7 +316,7 @@ parse_text(const BString& string, BTextView* textView, const BFont& font, // Cleanup states in case the input text had non-matching tags. while (state->previous != NULL) { - ParseState* oldState = state->previous; + ParseState* oldState = state; state = state->previous; delete oldState; } From 55d6e32c7d1d4e62bfee83d36142ca0953fda0dc Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sat, 21 Jul 2012 17:27:13 -0400 Subject: [PATCH 33/46] Fix name generation for void pointer parameters. --- src/apps/debugger/dwarf/DwarfUtils.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/apps/debugger/dwarf/DwarfUtils.cpp b/src/apps/debugger/dwarf/DwarfUtils.cpp index 233a41ca13..f32816101e 100644 --- a/src/apps/debugger/dwarf/DwarfUtils.cpp +++ b/src/apps/debugger/dwarf/DwarfUtils.cpp @@ -1,6 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. - * Copyright 2011, Rene Gollent, rene@gollent.com. + * Copyright 2011-2012, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -102,7 +102,7 @@ DwarfUtils::GetFullDIEName(const DebugInfoEntry* entry, BString& _name) type)) { DIEType* baseType = type; while ((modifiedType = dynamic_cast( - baseType)) != NULL && modifiedType->GetType() != NULL) { + baseType)) != NULL) { switch (modifiedType->Tag()) { case DW_TAG_pointer_type: modifier.Prepend("*"); @@ -122,7 +122,13 @@ DwarfUtils::GetFullDIEName(const DebugInfoEntry* entry, BString& _name) type = baseType; } - GetFullyQualifiedDIEName(type, paramName); + // if the parameter has no type associated, + // then it's the unspecified type. + if (type == NULL) + paramName = "void"; + else + GetFullyQualifiedDIEName(type, paramName); + if (modifier.Length() > 0) { if (modifier[modifier.Length() - 1] == ' ') modifier.Truncate(modifier.Length() - 1); From 1236c746afccdcf1ef33244cb1da655f3cf596dd Mon Sep 17 00:00:00 2001 From: Philippe Saint-Pierre Date: Sat, 21 Jul 2012 21:56:03 -0400 Subject: [PATCH 34/46] Tracker: a file leaving Trash won't appear in QueryPoseView Fixing #1592. A feedback FSNotification()->EntryMoved->PendingNodeMonitorCache->FSNotification was seemingly introducing some race condition, as it was working 1 time on several tries. --- src/kits/tracker/PoseView.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kits/tracker/PoseView.cpp b/src/kits/tracker/PoseView.cpp index 07bacbb1ac..1bc5078d98 100644 --- a/src/kits/tracker/PoseView.cpp +++ b/src/kits/tracker/PoseView.cpp @@ -5323,6 +5323,7 @@ BPoseView::EntryMoved(const BMessage *message) ReadPoseInfo(pose->TargetModel(), &poseInfo); if (!ShouldShowPose(pose->TargetModel(), &poseInfo)) return DeletePose(&itemNode, pose, index); + return true; } BPoint loc(0, index * fListElemHeight); @@ -5354,7 +5355,6 @@ BPoseView::EntryMoved(const BMessage *message) return DeletePose(&itemNode); else if (dirNode.node == thisDirNode.node) EntryCreated(&dirNode, &itemNode, name); - return true; } From b3b04af940fef90e722a590596527c6cc79920a3 Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Sun, 22 Jul 2012 11:06:48 -0500 Subject: [PATCH 35/46] usb_serial: Add new Option driver * Option devices are generally WWAN serial devices for 3G or lower. * Picks up my CMOTECH Sprint 3G adaptor, need to wire up endpoints so disabled for now. --- .../kernel/drivers/ports/usb_serial/Jamfile | 1 + .../drivers/ports/usb_serial/Option.cpp | 37 ++++++++++ .../kernel/drivers/ports/usb_serial/Option.h | 68 +++++++++++++++++++ .../drivers/ports/usb_serial/SerialDevice.cpp | 15 ++++ 4 files changed, 121 insertions(+) create mode 100644 src/add-ons/kernel/drivers/ports/usb_serial/Option.cpp create mode 100644 src/add-ons/kernel/drivers/ports/usb_serial/Option.h diff --git a/src/add-ons/kernel/drivers/ports/usb_serial/Jamfile b/src/add-ons/kernel/drivers/ports/usb_serial/Jamfile index c9521a221f..7fea83c129 100644 --- a/src/add-ons/kernel/drivers/ports/usb_serial/Jamfile +++ b/src/add-ons/kernel/drivers/ports/usb_serial/Jamfile @@ -14,6 +14,7 @@ KernelAddon usb_serial : ACM.cpp FTDI.cpp KLSI.cpp + Option.cpp Prolific.cpp Silicon.cpp ; diff --git a/src/add-ons/kernel/drivers/ports/usb_serial/Option.cpp b/src/add-ons/kernel/drivers/ports/usb_serial/Option.cpp new file mode 100644 index 0000000000..2b09e67b6c --- /dev/null +++ b/src/add-ons/kernel/drivers/ports/usb_serial/Option.cpp @@ -0,0 +1,37 @@ +/* + * Copyright 2011-2012 Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Alexander von Gluck IV, kallisti5@unixzen.com + */ + + +#include "Option.h" + + +OptionDevice::OptionDevice(usb_device device, uint16 vendorID, + uint16 productID, const char *description) + : + ACMDevice(device, vendorID, productID, description) +{ + TRACE_FUNCALLS("> OptionDevice found: %s\n", description); +} + + +status_t +OptionDevice::AddDevice(const usb_configuration_info *config) +{ + TRACE_FUNCALLS("> OptionDevice::AddDevice(%08x, %08x)\n", this, config); + + status_t status = B_OK; + return status; +} + + +status_t +OptionDevice::ResetDevice() +{ + TRACE_FUNCALLS("> OptionDevice::ResetDevice(%08x)\n", this); + return B_OK; +} diff --git a/src/add-ons/kernel/drivers/ports/usb_serial/Option.h b/src/add-ons/kernel/drivers/ports/usb_serial/Option.h new file mode 100644 index 0000000000..31204ed56f --- /dev/null +++ b/src/add-ons/kernel/drivers/ports/usb_serial/Option.h @@ -0,0 +1,68 @@ +/* + * Copyright 2011-2012 Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Alexander von Gluck IV, kallisti5@unixzen.com + */ +#ifndef _USB_OPTION_H_ +#define _USB_OPTION_H_ + + +#include "ACM.h" + + +/* supported vendor and product ids */ +#define VENDOR_AIRPLUS 0x1011 +#define VENDOR_ALCATEL 0x1bbb +#define VENDOR_ALINK 0x1e0e +#define VENDOR_AMOI 0x1614 +#define VENDOR_ANYDATA 0x16d5 +#define VENDOR_AXESSTEL 0x1726 +#define VENDOR_BANDRICH 0x1A8D +#define VENDOR_BENQ 0x04a5 +#define VENDOR_CELOT 0x211f +#define VENDOR_CMOTECH 0x16d8 +#define VENDOR_DELL 0x413C +#define VENDOR_DLINK 0x1186 +#define VENDOR_HAIER 0x201e +#define VENDOR_HUAWEI 0x12D1 +#define VENDOR_KYOCERA 0x0c88 +#define VENDOR_LG 0x1004 +#define VENDOR_LONGCHEER 0x1c9e +#define VENDOR_MEDIATEK 0x0e8d +#define VENDOR_NOVATEL 0x1410 +#define VENDOR_OLIVETTI 0x0b3c +#define VENDOR_ONDA 0x1ee8 +#define VENDOR_OPTION 0x0AF0 +#define VENDOR_QISDA 0x1da5 +#define VENDOR_QUALCOMM 0x05C6 +#define VENDOR_SAMSUNG 0x04e8 +#define VENDOR_TELIT 0x1bc7 +#define VENDOR_TLAYTECH 0x20B9 +#define VENDOR_TOSHIBA 0x0930 +#define VENDOR_VIETTEL 0x2262 +#define VENDOR_YISO 0x0EAB +#define VENDOR_YUGA 0x257A +#define VENDOR_ZD 0x0685 +#define VENDOR_ZTE 0x19d2 + +const usb_serial_device kOptionDevices[] = { + {VENDOR_CMOTECH, 0x6008, "CMOTECH CDMA Modem"}, + {VENDOR_CMOTECH, 0x5553, "CMOTECH CDU550"}, + {VENDOR_CMOTECH, 0x6512, "CMOTECH CDX650"} +}; + + +class OptionDevice : public ACMDevice { +public: + OptionDevice(usb_device device, + uint16 vendorID, uint16 productID, + const char *description); + + virtual status_t AddDevice(const usb_configuration_info *config); + virtual status_t ResetDevice(); +}; + + +#endif /*_USB_OPTION_H_ */ diff --git a/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.cpp b/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.cpp index 2d8e62e528..9c888789ed 100644 --- a/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.cpp +++ b/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.cpp @@ -18,6 +18,7 @@ #include "ACM.h" #include "FTDI.h" #include "KLSI.h" +#include "Option.h" #include "Prolific.h" #include "Silicon.h" @@ -759,6 +760,20 @@ SerialDevice::MakeDevice(usb_device device, uint16 vendorID, } } + #if 0 + // Not yet working + + // Option Serial Device + for (uint32 i = 0; i < sizeof(kOptionDevices) + / sizeof(kOptionDevices[0]); i++) { + if (vendorID == kOptionDevices[i].vendorID + && productID == kOptionDevices[i].productID) { + return new(std::nothrow) OptionDevice(device, vendorID, productID, + kOptionDevices[i].deviceName); + } + } + #endif + // Otherwise, return standard ACM device return new(std::nothrow) ACMDevice(device, vendorID, productID, "CDC ACM compatible device"); From 52b7ccf49e8215e58c9c341e013999ee1795848b Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Sun, 22 Jul 2012 11:57:25 -0500 Subject: [PATCH 36/46] usb_serial: Probe for USB endpoints on Option device * More then one serial port is common, for now we only work off of the first one detected. * Still disabled as some setup is needed. --- .../drivers/ports/usb_serial/Option.cpp | 54 ++++++++++++++++++- .../drivers/ports/usb_serial/SerialDevice.cpp | 10 ++-- 2 files changed, 57 insertions(+), 7 deletions(-) diff --git a/src/add-ons/kernel/drivers/ports/usb_serial/Option.cpp b/src/add-ons/kernel/drivers/ports/usb_serial/Option.cpp index 2b09e67b6c..8c0de2a0f7 100644 --- a/src/add-ons/kernel/drivers/ports/usb_serial/Option.cpp +++ b/src/add-ons/kernel/drivers/ports/usb_serial/Option.cpp @@ -24,8 +24,58 @@ OptionDevice::AddDevice(const usb_configuration_info *config) { TRACE_FUNCALLS("> OptionDevice::AddDevice(%08x, %08x)\n", this, config); - status_t status = B_OK; - return status; + if (config->interface_count > 0) { + for (size_t index = 0; index < config->interface_count; index++) { + usb_interface_info *interface = config->interface[index].active; + + int txEndpointID = -1; + int rxEndpointID = -1; + int irEndpointID = -1; + + for (size_t i = 0; i < interface->endpoint_count; i++) { + usb_endpoint_info *endpoint = &interface->endpoint[i]; + + // Find our Interrupt endpoint + if (endpoint->descr->attributes == USB_ENDPOINT_ATTR_INTERRUPT + && (endpoint->descr->endpoint_address + & USB_ENDPOINT_ADDR_DIR_IN) != 0) { + irEndpointID = i; + continue; + } + + // Find our Transmit / Receive endpoints + if (endpoint->descr->attributes == USB_ENDPOINT_ATTR_BULK) { + if ((endpoint->descr->endpoint_address + & USB_ENDPOINT_ADDR_DIR_IN) != 0) { + rxEndpointID = i; + } else { + txEndpointID = i; + } + continue; + } + } + + TRACE("> OptionDevice::%s: endpoint %d, tx: %d, rx: %d, ir: %d\n", + __func__, index, txEndpointID, rxEndpointID, irEndpointID); + + if (txEndpointID < 0 || rxEndpointID < 0 || irEndpointID < 0) + continue; + + TRACE("> OptionDevice::%s: found at interface %d\n", __func__, + index); + usb_endpoint_info *irEndpoint = &interface->endpoint[irEndpointID]; + usb_endpoint_info *txEndpoint = &interface->endpoint[irEndpointID]; + usb_endpoint_info *rxEndpoint = &interface->endpoint[irEndpointID]; + SetControlPipe(irEndpoint->handle); + SetReadPipe(rxEndpoint->handle); + SetWritePipe(txEndpoint->handle); + + // We accept the first found serial interface + // TODO: We should set each matching interface up (can be > 1) + return B_OK; + } + } + return ENODEV; } diff --git a/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.cpp b/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.cpp index 9c888789ed..e3d1694195 100644 --- a/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.cpp +++ b/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.cpp @@ -725,7 +725,7 @@ SerialDevice::MakeDevice(usb_device device, uint16 vendorID, / sizeof(kFTDIDevices[0]); i++) { if (vendorID == kFTDIDevices[i].vendorID && productID == kFTDIDevices[i].productID) { - return new(std::nothrow) FTDIDevice(device, vendorID, productID, + return new(std::nothrow) FTDIDevice(device, vendorID, productID, kFTDIDevices[i].deviceName); } } @@ -735,7 +735,7 @@ SerialDevice::MakeDevice(usb_device device, uint16 vendorID, / sizeof(kKLSIDevices[0]); i++) { if (vendorID == kKLSIDevices[i].vendorID && productID == kKLSIDevices[i].productID) { - return new(std::nothrow) KLSIDevice(device, vendorID, productID, + return new(std::nothrow) KLSIDevice(device, vendorID, productID, kKLSIDevices[i].deviceName); } } @@ -745,7 +745,7 @@ SerialDevice::MakeDevice(usb_device device, uint16 vendorID, / sizeof(kProlificDevices[0]); i++) { if (vendorID == kProlificDevices[i].vendorID && productID == kProlificDevices[i].productID) { - return new(std::nothrow) ProlificDevice(device, vendorID, productID, + return new(std::nothrow) ProlificDevice(device, vendorID, productID, kProlificDevices[i].deviceName); } } @@ -755,7 +755,7 @@ SerialDevice::MakeDevice(usb_device device, uint16 vendorID, / sizeof(kSiliconDevices[0]); i++) { if (vendorID == kSiliconDevices[i].vendorID && productID == kSiliconDevices[i].productID) { - return new(std::nothrow) SiliconDevice(device, vendorID, productID, + return new(std::nothrow) SiliconDevice(device, vendorID, productID, kSiliconDevices[i].deviceName); } } @@ -768,7 +768,7 @@ SerialDevice::MakeDevice(usb_device device, uint16 vendorID, / sizeof(kOptionDevices[0]); i++) { if (vendorID == kOptionDevices[i].vendorID && productID == kOptionDevices[i].productID) { - return new(std::nothrow) OptionDevice(device, vendorID, productID, + return new(std::nothrow) OptionDevice(device, vendorID, productID, kOptionDevices[i].deviceName); } } From 8899214980d031c69441a29c5c122e3fd592d0b7 Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Sun, 22 Jul 2012 12:06:27 -0500 Subject: [PATCH 37/46] usb_serial: Fix typo, set up endpoints properly * Can successfully send data to Option USB serial device now (I need to do some testing before turning it on though) --- src/add-ons/kernel/drivers/ports/usb_serial/Option.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/add-ons/kernel/drivers/ports/usb_serial/Option.cpp b/src/add-ons/kernel/drivers/ports/usb_serial/Option.cpp index 8c0de2a0f7..d82812d6dd 100644 --- a/src/add-ons/kernel/drivers/ports/usb_serial/Option.cpp +++ b/src/add-ons/kernel/drivers/ports/usb_serial/Option.cpp @@ -64,8 +64,8 @@ OptionDevice::AddDevice(const usb_configuration_info *config) TRACE("> OptionDevice::%s: found at interface %d\n", __func__, index); usb_endpoint_info *irEndpoint = &interface->endpoint[irEndpointID]; - usb_endpoint_info *txEndpoint = &interface->endpoint[irEndpointID]; - usb_endpoint_info *rxEndpoint = &interface->endpoint[irEndpointID]; + usb_endpoint_info *txEndpoint = &interface->endpoint[txEndpointID]; + usb_endpoint_info *rxEndpoint = &interface->endpoint[rxEndpointID]; SetControlPipe(irEndpoint->handle); SetReadPipe(rxEndpoint->handle); SetWritePipe(txEndpoint->handle); From 7e67ec90a46ec4202ab7e4f7b0e07cf398200f45 Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Sun, 22 Jul 2012 13:48:57 -0500 Subject: [PATCH 38/46] usb_serial: Set option driver to use the last found port. * Add a warning when >1 port is found (as we only use the last found serial port) * Verified working, remove if 0. --- .../kernel/drivers/ports/usb_serial/Option.cpp | 16 +++++++++++++--- .../drivers/ports/usb_serial/SerialDevice.cpp | 4 ---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/add-ons/kernel/drivers/ports/usb_serial/Option.cpp b/src/add-ons/kernel/drivers/ports/usb_serial/Option.cpp index d82812d6dd..2041d8fe24 100644 --- a/src/add-ons/kernel/drivers/ports/usb_serial/Option.cpp +++ b/src/add-ons/kernel/drivers/ports/usb_serial/Option.cpp @@ -24,6 +24,7 @@ OptionDevice::AddDevice(const usb_configuration_info *config) { TRACE_FUNCALLS("> OptionDevice::AddDevice(%08x, %08x)\n", this, config); + int portsFound = 0; if (config->interface_count > 0) { for (size_t index = 0; index < config->interface_count; index++) { usb_interface_info *interface = config->interface[index].active; @@ -61,17 +62,26 @@ OptionDevice::AddDevice(const usb_configuration_info *config) if (txEndpointID < 0 || rxEndpointID < 0 || irEndpointID < 0) continue; - TRACE("> OptionDevice::%s: found at interface %d\n", __func__, + TRACE("> OptionDevice::%s: found port at interface %d\n", __func__, index); + portsFound++; + usb_endpoint_info *irEndpoint = &interface->endpoint[irEndpointID]; usb_endpoint_info *txEndpoint = &interface->endpoint[txEndpointID]; usb_endpoint_info *rxEndpoint = &interface->endpoint[rxEndpointID]; SetControlPipe(irEndpoint->handle); SetReadPipe(rxEndpoint->handle); SetWritePipe(txEndpoint->handle); + } - // We accept the first found serial interface - // TODO: We should set each matching interface up (can be > 1) + // TODO: We need to handle multiple ports + // We use the last found serial port for now + if (portsFound > 0) { + if (portsFound > 1) { + TRACE_ALWAYS("> OptionDevice::%s: Warning: Found more than one " + "serial port on this device (%d). Only the last one is " + "is used.\n", __func__, portsFound); + } return B_OK; } } diff --git a/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.cpp b/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.cpp index e3d1694195..e8bb192c35 100644 --- a/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.cpp +++ b/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.cpp @@ -760,9 +760,6 @@ SerialDevice::MakeDevice(usb_device device, uint16 vendorID, } } - #if 0 - // Not yet working - // Option Serial Device for (uint32 i = 0; i < sizeof(kOptionDevices) / sizeof(kOptionDevices[0]); i++) { @@ -772,7 +769,6 @@ SerialDevice::MakeDevice(usb_device device, uint16 vendorID, kOptionDevices[i].deviceName); } } - #endif // Otherwise, return standard ACM device return new(std::nothrow) ACMDevice(device, vendorID, productID, From d7ed9414a3260efaed0fa9de5dde9bb8c0bc11ef Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sun, 22 Jul 2012 15:53:19 -0400 Subject: [PATCH 39/46] Fix #8523. - When the message filter would receive and process a mouse moved message, if the message resulted in causing the deskbar to relocate or reorient itself, it was possible for the expando view to become detached from the looper. Consequently, if the intercepted mouse moved happened to have come from the latter, when returning out of the filter the view would no longer have a target looper, triggering a debugger condition in BLooper. In order to prevent this situation, we now dispatch a message asking for the layout change to occur asynchronously. --- src/apps/deskbar/BarView.cpp | 75 ++++++++++++++++++++++++--------- src/apps/deskbar/BarView.h | 5 ++- src/apps/deskbar/StatusView.cpp | 2 +- 3 files changed, 60 insertions(+), 22 deletions(-) diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp index 8fb1715936..44248e06d0 100644 --- a/src/apps/deskbar/BarView.cpp +++ b/src/apps/deskbar/BarView.cpp @@ -69,6 +69,8 @@ const int32 kDefaultRecentAppCount = 10; const int32 kMenuTrackMargin = 20; +const uint32 kUpdateOrientation = 'UpOr'; + class BarViewMessageFilter : public BMessageFilter { @@ -102,7 +104,7 @@ BarViewMessageFilter::Filter(BMessage* message, BHandler** target) if (message->what == B_MOUSE_DOWN || message->what == B_MOUSE_MOVED) { BPoint where = message->FindPoint("be:view_where"); uint32 transit = message->FindInt32("be:transit"); - BMessage *dragMessage = NULL; + BMessage* dragMessage = NULL; if (message->HasMessage("be:drag_message")) { dragMessage = new BMessage(); message->FindMessage("be:drag_message", dragMessage); @@ -140,7 +142,8 @@ TBarView::TBarView(BRect frame, bool vertical, bool left, bool top, fCachedTypesList(NULL), fMaxRecentDocs(kDefaultRecentDocCount), fMaxRecentApps(kDefaultRecentAppCount), - fLastDragItem(NULL) + fLastDragItem(NULL), + fMouseFilter(NULL) { fReplicantTray = new TReplicantTray(this, fVertical); fDragRegion = new TDragRegion(this, fReplicantTray); @@ -167,7 +170,8 @@ TBarView::AttachedToWindow() SetViewColor(ui_color(B_MENU_BACKGROUND_COLOR)); SetFont(be_plain_font); - Window()->AddCommonFilter(new BarViewMessageFilter(this)); + fMouseFilter = new BarViewMessageFilter(this); + Window()->AddCommonFilter(fMouseFilter); UpdatePlacement(); @@ -180,6 +184,9 @@ TBarView::AttachedToWindow() void TBarView::DetachedFromWindow() { + Window()->RemoveCommonFilter(fMouseFilter); + delete fMouseFilter; + fMouseFilter = NULL; delete fTrackingHookData.fDragMessage; fTrackingHookData.fDragMessage = NULL; } @@ -232,6 +239,12 @@ TBarView::MessageReceived(BMessage* message) break; } + case kUpdateOrientation: + { + _ChangeState(message); + break; + } + default: BView::MessageReceived(message); } @@ -588,25 +601,19 @@ TBarView::UpdatePlacement() void -TBarView::ChangeState(int32 state, bool vertical, bool left, bool top) +TBarView::ChangeState(int32 state, bool vertical, bool left, bool top, + bool async) { - bool vertSwap = (fVertical != vertical); - bool leftSwap = (fLeft != left); - bool stateChanged = (fState != state); + BMessage message(kUpdateOrientation); + message.AddInt32("state", state); + message.AddBool("vertical", vertical); + message.AddBool("left", left); + message.AddBool("top", top); - fState = state; - fVertical = vertical; - fLeft = left; - fTop = top; - - // Send a message to the preferences window to let it know to enable - // or disable preference items - if (stateChanged || vertSwap) - be_app->PostMessage(kStateChanged); - - PlaceDeskbarMenu(); - PlaceTray(vertSwap, leftSwap); - PlaceApplicationBar(); + if (async) + BMessenger(this).SendMessage(&message); + else + _ChangeState(&message); } @@ -677,6 +684,34 @@ TBarView::ExpandItems() } +void +TBarView::_ChangeState(BMessage* message) +{ + int32 state = message->FindInt32("state"); + bool vertical = message->FindBool("vertical"); + bool left = message->FindBool("left"); + bool top = message->FindBool("top"); + + bool vertSwap = (fVertical != vertical); + bool leftSwap = (fLeft != left); + bool stateChanged = (fState != state); + + fState = state; + fVertical = vertical; + fLeft = left; + fTop = top; + + // Send a message to the preferences window to let it know to enable + // or disable preference items + if (stateChanged || vertSwap) + be_app->PostMessage(kStateChanged); + + PlaceDeskbarMenu(); + PlaceTray(vertSwap, leftSwap); + PlaceApplicationBar(); +} + + void TBarView::AddExpandedItem(const char* signature) { diff --git a/src/apps/deskbar/BarView.h b/src/apps/deskbar/BarView.h index 293bed7ea5..f375c872d4 100644 --- a/src/apps/deskbar/BarView.h +++ b/src/apps/deskbar/BarView.h @@ -90,7 +90,8 @@ class TBarView : public BView { void SaveSettings(); void UpdatePlacement(); - void ChangeState(int32 state, bool vertical, bool left, bool top); + void ChangeState(int32 state, bool vertical, bool left, bool top, + bool aSync = false); void RaiseDeskbar(bool raise); void HideDeskbar(bool hide); @@ -165,6 +166,7 @@ class TBarView : public BView { void SaveExpandedItems(); void RemoveExpandedItems(); void ExpandItems(); + void _ChangeState(BMessage* message); TBarMenuBar* fBarMenuBar; TExpandoMenuBar* fExpando; @@ -190,6 +192,7 @@ class TBarView : public BView { TTeamMenuItem* fLastDragItem; BList fExpandedItems; + BMessageFilter* fMouseFilter; }; diff --git a/src/apps/deskbar/StatusView.cpp b/src/apps/deskbar/StatusView.cpp index e32b769839..4b2df60065 100644 --- a/src/apps/deskbar/StatusView.cpp +++ b/src/apps/deskbar/StatusView.cpp @@ -1483,7 +1483,7 @@ TDragRegion::SwitchModeForRect(BPoint mouse, BRect rect, return true; } - fBarView->ChangeState(newState, newVertical, newLeft, newTop); + fBarView->ChangeState(newState, newVertical, newLeft, newTop, true); return true; } From 47a394ec139b7defdd57aeea2587f435716aa172 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Sun, 22 Jul 2012 13:22:48 -0400 Subject: [PATCH 40/46] Replace calls to DragRegion() with fDragRegion avoiding a function call. Move variables in MouseMoved down to just before they are used. --- src/apps/deskbar/BarView.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp index 44248e06d0..c2a9e26141 100644 --- a/src/apps/deskbar/BarView.cpp +++ b/src/apps/deskbar/BarView.cpp @@ -254,19 +254,19 @@ TBarView::MessageReceived(BMessage* message) void TBarView::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage) { - desk_settings* settings = ((TBarApp*)be_app)->Settings(); - bool alwaysOnTop = settings->alwaysOnTop; - bool autoRaise = settings->autoRaise; - bool autoHide = settings->autoHide; - - if (DragRegion()->IsDragging()) { - DragRegion()->MouseMoved(where, transit, dragMessage); + if (fDragRegion->IsDragging()) { + fDragRegion->MouseMoved(where, transit, dragMessage); return; } if (transit == B_ENTERED_VIEW && EventMask() == 0) SetEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY); + desk_settings* settings = ((TBarApp*)be_app)->Settings(); + bool alwaysOnTop = settings->alwaysOnTop; + bool autoRaise = settings->autoRaise; + bool autoHide = settings->autoHide; + if (!autoRaise && !autoHide) { if (transit == B_EXITED_VIEW || transit == B_OUTSIDE_VIEW) SetEventMask(0); @@ -324,8 +324,7 @@ TBarView::MouseDown(BPoint where) if ((modifiers() & (B_CONTROL_KEY | B_COMMAND_KEY | B_OPTION_KEY | B_SHIFT_KEY)) == (B_CONTROL_KEY | B_COMMAND_KEY)) { // The window key was pressed - enter dragging code - DragRegion()->MouseDown( - DragRegion()->DragRegion().LeftTop()); + fDragRegion->MouseDown(fDragRegion->DragRegion().LeftTop()); return; } } else { @@ -504,7 +503,7 @@ TBarView::GetPreferredWindowSize(BRect screenFrame, float* width, float* height) float windowHeight = 0; float windowWidth = sMinimumWindowWidth; bool setToHiddenSize = ((TBarApp*)be_app)->Settings()->autoHide - && IsHidden() && !DragRegion()->IsDragging(); + && IsHidden() && !fDragRegion->IsDragging(); int32 iconSize = static_cast(be_app)->IconSize(); if (setToHiddenSize) { From 8f29b6e639c5fb96e5f5ccd3f197ad94fee6ce15 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Sun, 22 Jul 2012 13:53:06 -0400 Subject: [PATCH 41/46] indent break statements. Only delete dragMessage if not NULL. --- src/apps/deskbar/BarView.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp index c2a9e26141..4e913035bb 100644 --- a/src/apps/deskbar/BarView.cpp +++ b/src/apps/deskbar/BarView.cpp @@ -113,14 +113,15 @@ BarViewMessageFilter::Filter(BMessage* message, BHandler** target) switch (message->what) { case B_MOUSE_DOWN: fBarView->MouseDown(where); - break; + break; case B_MOUSE_MOVED: fBarView->MouseMoved(where, transit, dragMessage); - break; + break; } - delete dragMessage; + if (message->HasMessage("be:drag_message")) + delete dragMessage; } return B_DISPATCH_MESSAGE; From 8cf6d28f996f132095d5f61c0b5622168c39ae91 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Sun, 22 Jul 2012 15:58:31 -0400 Subject: [PATCH 42/46] It is okay to delete dragMessage even if it is NULL. Not worth the branch. --- src/apps/deskbar/BarView.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp index 4e913035bb..0bc16d2f6f 100644 --- a/src/apps/deskbar/BarView.cpp +++ b/src/apps/deskbar/BarView.cpp @@ -120,8 +120,7 @@ BarViewMessageFilter::Filter(BMessage* message, BHandler** target) break; } - if (message->HasMessage("be:drag_message")) - delete dragMessage; + delete dragMessage; } return B_DISPATCH_MESSAGE; From 674ff0df2f2eb00cbc78b4384fcf5b148a2139ff Mon Sep 17 00:00:00 2001 From: Philippe Saint-Pierre Date: Sun, 22 Jul 2012 22:04:28 -0400 Subject: [PATCH 43/46] Tracker: Various sorting issues in Tracker When sorting files by Modified dates, right clicking on a file was leading to a sorting issue where files were changing positions (without reason). 1. Any changes to stats (size, modification, creation, mode) was triggering the sorting. Now only stats fields currently used as a Sort criteria will trigger such event. 2. The Mimeset of file was set (in case of unknown file format) once per checked add-on when building AddOn Menu. Now it's checked once per file in selection. (so, once per file, rather then once per file, per add-on). 3. Now rely on registrar to force the mimeset (to trigger the sniffer in case the attribute already exist) rather than trying to duplicate the feature in Tracker. 4. When Sorting, if there is a old position known, check if it's working by looking if you should come after the previous item, and before the following item. Previously, the item would be pushed at the top if the group of item all fitting the criteria (same file size, same file kind, etc.. depending on the sorting criteria). Fixes #8478. --- src/kits/tracker/ContainerWindow.cpp | 32 +++++++++--- src/kits/tracker/ContainerWindow.h | 2 + src/kits/tracker/Model.cpp | 11 +---- src/kits/tracker/PoseView.cpp | 74 ++++++++++++++++++++++------ src/kits/tracker/PoseView.h | 3 +- 5 files changed, 92 insertions(+), 30 deletions(-) diff --git a/src/kits/tracker/ContainerWindow.cpp b/src/kits/tracker/ContainerWindow.cpp index bcbb092d4f..b48b683e77 100644 --- a/src/kits/tracker/ContainerWindow.cpp +++ b/src/kits/tracker/ContainerWindow.cpp @@ -318,12 +318,7 @@ static void AddMimeTypeString(BObjectList &list, Model *model) { BString *mimeType = new BString(model->MimeType()); - if (!mimeType->Length() || !mimeType->ICompare(B_FILE_MIMETYPE)) { - // if model is of unknown type, try mimeseting it first - model->Mimeset(true); - mimeType->SetTo(model->MimeType()); - } - + if (mimeType->Length()) { // only add the type if it's not already there for (int32 i = list.CountItems(); i-- > 0;) { @@ -2975,6 +2970,8 @@ BContainerWindow::BuildAddOnMenu(BMenu *menu) break; delete item; } + + _UpdateSelectionMIMEInfo(); BObjectList primaryList; BObjectList secondaryList; @@ -3141,6 +3138,29 @@ BContainerWindow::LoadAddOn(BMessage *message) } +void +BContainerWindow::_UpdateSelectionMIMEInfo() +{ + BPose* pose; + int32 index = 0; + while ((pose = PoseView()->SelectionList()->ItemAt(index++)) != NULL) { + BString mimeType(pose->TargetModel()->MimeType()); + if (!mimeType.Length() || mimeType.ICompare(B_FILE_MIMETYPE) == 0) { + pose->TargetModel()->Mimeset(true); + if (pose->TargetModel()->IsSymLink()) { + Model* resolved = new Model(pose->TargetModel()->EntryRef(), true, true); + if (resolved->InitCheck() == B_OK) { + mimeType.SetTo(resolved->MimeType()); + if (!mimeType.Length() || mimeType.ICompare(B_FILE_MIMETYPE) == 0) + resolved->Mimeset(true); + } + delete resolved; + } + } + } +} + + BMenuItem * BContainerWindow::NewAttributeMenuItem(const char *label, const char *name, int32 type, float width, int32 align, bool editable, bool statField) diff --git a/src/kits/tracker/ContainerWindow.h b/src/kits/tracker/ContainerWindow.h index 5bee938731..373b81a7a1 100644 --- a/src/kits/tracker/ContainerWindow.h +++ b/src/kits/tracker/ContainerWindow.h @@ -303,6 +303,8 @@ class BContainerWindow : public BWindow { friend int32 show_context_menu(void*); friend class BackgroundView; + + void _UpdateSelectionMIMEInfo(); }; class WindowStateNodeOpener { diff --git a/src/kits/tracker/Model.cpp b/src/kits/tracker/Model.cpp index 392b8e4d08..7f5ea56b7f 100644 --- a/src/kits/tracker/Model.cpp +++ b/src/kits/tracker/Model.cpp @@ -1178,18 +1178,11 @@ bool Model::Mimeset(bool force) { BString oldType = MimeType(); - ModelNodeLazyOpener opener(this); BPath path; GetPath(&path); - if (force) { - if (opener.OpenNode(true) != B_OK) - return false; - - Node()->RemoveAttr(kAttrMIMEType); - update_mime_info(path.Path(), 0, 1, 1); - } else - update_mime_info(path.Path(), 0, 1, 0); + update_mime_info(path.Path(), 0, 1, force ? 2 : 0); + AttrChanged(0); return !oldType.ICompare(MimeType()); diff --git a/src/kits/tracker/PoseView.cpp b/src/kits/tracker/PoseView.cpp index 1bc5078d98..0a69b0eaf2 100644 --- a/src/kits/tracker/PoseView.cpp +++ b/src/kits/tracker/PoseView.cpp @@ -1674,7 +1674,7 @@ BPoseView::AddPoseToList(PoseList *list, bool visibleList, bool insertionSort, bool needToDraw = true; if (insertionSort && list->CountItems()) { - int32 orientation = BSearchList(list, pose, &poseIndex); + int32 orientation = BSearchList(list, pose, &poseIndex, 0); if (orientation == kInsertAfter) poseIndex++; @@ -5359,6 +5359,12 @@ BPoseView::EntryMoved(const BMessage *message) } +struct attrColumnRelation { + uint32 attrHash; + int32 fieldMask; +}; + + bool BPoseView::AttributeChanged(const BMessage *message) { @@ -5430,7 +5436,6 @@ BPoseView::AttributeChanged(const BMessage *message) return false; } - uint32 attrHash; if (attrName) { // rebuild the MIME type list, if the MIME type has changed if (strcmp(attrName, kAttrMIMEType) == 0) @@ -5438,14 +5443,41 @@ BPoseView::AttributeChanged(const BMessage *message) // note: the following code is wrong, because this sort of hashing // may overlap and we get aliasing - attrHash = AttrHashString(attrName, info.type); - } + uint32 attrHash = AttrHashString(attrName, info.type); + if (attrHash == PrimarySort() || attrHash == SecondarySort()) { + _CheckPoseSortOrder(fPoseList, pose, poseListIndex); + if (fFiltering && visible) + _CheckPoseSortOrder(fFilteredPoseList, pose, index); + } + } else { + int32 fields; + if (message->FindInt32("fields", &fields) != B_OK) + return true; - if (!attrName || attrHash == PrimarySort() - || attrHash == SecondarySort()) { - _CheckPoseSortOrder(fPoseList, pose, poseListIndex); - if (fFiltering && visible) - _CheckPoseSortOrder(fFilteredPoseList, pose, index); + static struct attrColumnRelation attributs[] = { + { AttrHashString(kAttrStatModified, B_TIME_TYPE), + B_STAT_MODIFICATION_TIME }, + { AttrHashString(kAttrStatSize, B_OFF_T_TYPE), + B_STAT_SIZE }, + { AttrHashString(kAttrStatCreated, B_TIME_TYPE), + B_STAT_CREATION_TIME }, + { AttrHashString(kAttrStatMode, B_STRING_TYPE), + B_STAT_MODE } + }; + + for (int32 i = sizeof(attributs) / sizeof(attrColumnRelation); + i--;) { + if (attributs[i].attrHash == PrimarySort() + || attributs[i].attrHash == SecondarySort()) { + + if (fields & attributs[i].fieldMask) { + _CheckPoseSortOrder(fPoseList, pose, poseListIndex); + if (fFiltering && visible) + _CheckPoseSortOrder(fFilteredPoseList, pose, index); + return true; + } + } + } } } else { // we received an attr changed notification for a zombie model, it means @@ -8667,7 +8699,7 @@ BPoseView::_CheckPoseSortOrder(PoseList *poseList, BPose *pose, int32 oldIndex) // take pose out of list for BSearch poseList->RemoveItemAt(oldIndex); int32 afterIndex; - int32 orientation = BSearchList(poseList, pose, &afterIndex); + int32 orientation = BSearchList(poseList, pose, &afterIndex, oldIndex); int32 newIndex; if (orientation == kInsertAtFront) @@ -8777,19 +8809,33 @@ BSearch(PoseList *table, const BPose* key, BPoseView *view, int32 BPoseView::BSearchList(PoseList *poseList, const BPose *pose, - int32 *resultingIndex) + int32 *resultingIndex, int32 oldIndex) { // check to see if insertion should be at beginning of list const BPose *firstPose = poseList->FirstItem(); if (!firstPose) - return kInsertAtFront; - - if (PoseCompareAddWidget(pose, firstPose, this) <= 0) { + return kInsertAtFront; + + if (PoseCompareAddWidget(pose, firstPose, this) < 0) { *resultingIndex = 0; return kInsertAtFront; } int32 count = poseList->CountItems(); + + // look if old position is still ok, by comparing to siblings + bool valid = oldIndex > 0 && oldIndex < count - 1; + valid = valid && PoseCompareAddWidget(pose, + poseList->ItemAt(oldIndex - 1), this) >= 0; + // the current item is gone, so not oldIndex+1 + valid = valid && PoseCompareAddWidget(pose, + poseList->ItemAt(oldIndex), this) <= 0; + + if (valid) { + *resultingIndex = oldIndex - 1; + return kInsertAfter; + } + *resultingIndex = count - 1; const BPose *searchResult = BSearch(poseList, pose, this, diff --git a/src/kits/tracker/PoseView.h b/src/kits/tracker/PoseView.h index 65a7f6a802..ce6fd0b728 100644 --- a/src/kits/tracker/PoseView.h +++ b/src/kits/tracker/PoseView.h @@ -520,7 +520,8 @@ class BPoseView : public BView { void DrawViewCommon(const BRect &updateRect); // pose list handling - int32 BSearchList(PoseList *poseList, const BPose *, int32 *index); + int32 BSearchList(PoseList *poseList, const BPose *, int32 *index, + int32 oldIndex); void InsertPoseAfter(BPose *pose, int32 *index, int32 orientation, BRect *invalidRect); // does a CopyBits to scroll poses making room for a new pose, From 516cac7817d0b2f54e8b59acfff5cf803ef7d2ab Mon Sep 17 00:00:00 2001 From: Philippe Saint-Pierre Date: Mon, 23 Jul 2012 08:21:43 -0400 Subject: [PATCH 44/46] Tracker: Coding style violations fixes and typos No functional changes, thanks Axel! --- src/kits/tracker/PoseView.cpp | 44 +++++++++++++++++------------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/kits/tracker/PoseView.cpp b/src/kits/tracker/PoseView.cpp index 0a69b0eaf2..592c04b0d0 100644 --- a/src/kits/tracker/PoseView.cpp +++ b/src/kits/tracker/PoseView.cpp @@ -149,6 +149,24 @@ const BPoint kTransparentDragThreshold(256, 192); // if larger in any direction +struct attr_column_relation { + uint32 attrHash; + int32 fieldMask; +}; + + +static struct attr_column_relation attributes[] = { + { AttrHashString(kAttrStatModified, B_TIME_TYPE), + B_STAT_MODIFICATION_TIME }, + { AttrHashString(kAttrStatSize, B_OFF_T_TYPE), + B_STAT_SIZE }, + { AttrHashString(kAttrStatCreated, B_TIME_TYPE), + B_STAT_CREATION_TIME }, + { AttrHashString(kAttrStatMode, B_STRING_TYPE), + B_STAT_MODE } +}; + + struct AddPosesResult { ~AddPosesResult(); void ReleaseModels(); @@ -5359,12 +5377,6 @@ BPoseView::EntryMoved(const BMessage *message) } -struct attrColumnRelation { - uint32 attrHash; - int32 fieldMask; -}; - - bool BPoseView::AttributeChanged(const BMessage *message) { @@ -5454,23 +5466,11 @@ BPoseView::AttributeChanged(const BMessage *message) if (message->FindInt32("fields", &fields) != B_OK) return true; - static struct attrColumnRelation attributs[] = { - { AttrHashString(kAttrStatModified, B_TIME_TYPE), - B_STAT_MODIFICATION_TIME }, - { AttrHashString(kAttrStatSize, B_OFF_T_TYPE), - B_STAT_SIZE }, - { AttrHashString(kAttrStatCreated, B_TIME_TYPE), - B_STAT_CREATION_TIME }, - { AttrHashString(kAttrStatMode, B_STRING_TYPE), - B_STAT_MODE } - }; - - for (int32 i = sizeof(attributs) / sizeof(attrColumnRelation); + for (int32 i = sizeof(attributes) / sizeof(attr_column_relation); i--;) { - if (attributs[i].attrHash == PrimarySort() - || attributs[i].attrHash == SecondarySort()) { - - if (fields & attributs[i].fieldMask) { + if (attributes[i].attrHash == PrimarySort() + || attributes[i].attrHash == SecondarySort()) { + if ((fields & attributes[i].fieldMask) != 0) { _CheckPoseSortOrder(fPoseList, pose, poseListIndex); if (fFiltering && visible) _CheckPoseSortOrder(fFilteredPoseList, pose, index); From b6a70ecba9f72f2350e95e8060ecf72b45183448 Mon Sep 17 00:00:00 2001 From: Philippe Saint-Pierre Date: Mon, 23 Jul 2012 10:16:37 -0400 Subject: [PATCH 45/46] ProcessController: fix display of CPU bars for systems having 3 cores Generalize the drawing of separator lines for every number of cores requesting them. Fix the layout for 3 cores systems. Should fix #8763. --- src/apps/processcontroller/ProcessController.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/apps/processcontroller/ProcessController.cpp b/src/apps/processcontroller/ProcessController.cpp index d70c7361a0..1a5d5d20cc 100644 --- a/src/apps/processcontroller/ProcessController.cpp +++ b/src/apps/processcontroller/ProcessController.cpp @@ -124,7 +124,7 @@ layoutT layout[] = { { 1, 1, 1 }, { 5, 1, 5 }, // 1 { 3, 1, 4 }, // 2 - { 1, 1, 1 }, + { 2, 1, 3 }, { 2, 0, 3 }, // 4 { 1, 1, 1 }, { 1, 1, 1 }, @@ -542,16 +542,17 @@ ProcessController::DoDraw(bool force) float right = left + gCPUcount * (barWidth + layout[gCPUcount].cpu_inter) - layout[gCPUcount].cpu_inter; // right of CPU frame... if (force && Parent()) { - SetHighColor(Parent()->ViewColor ()); + SetHighColor(Parent()->ViewColor()); FillRect(BRect(right + 1, top - 1, right + 2, bottom + 1)); } if (force) { SetHighColor(frame_color); StrokeRect(BRect(left - 1, top - 1, right, bottom + 1)); - if (gCPUcount == 2) { - StrokeLine(BPoint(left + barWidth, top), BPoint(left + barWidth, - bottom)); + if (gCPUcount > 1 && layout[gCPUcount].cpu_inter == 1) { + for (int x = 1; x < gCPUcount; x++) + StrokeLine(BPoint(left + x * barWidth + x - 1, top), + BPoint(left + x * barWidth + x - 1, bottom)); } } float leftMem = bounds.Width() - layout[gCPUcount].mem_width; @@ -592,9 +593,9 @@ ProcessController::DoDraw(bool force) fLastBarHeight[x] = barHeight; } - float rightMem = bounds.Width () - 1; + float rightMem = bounds.Width() - 1; float rem = fMemoryUsage * (h + 1); - float barHeight = floorf (rem); + float barHeight = floorf(rem); rem -= barHeight; rgb_color used_memory_color; From 5cdd07a8148b04cd1b7e29778ec0661df7dbe46d Mon Sep 17 00:00:00 2001 From: Philippe Saint-Pierre Date: Mon, 23 Jul 2012 14:47:24 -0400 Subject: [PATCH 46/46] Tracker: Optimisation of AddonMenu menu construction 1. Build the list of mimetypes of files in selection only once and reuse it for all further tests. 2. Fix a regression introduced in hrev44384 where the MimeType() wouldn't get recognized when just changed by tracker (by that same right click). It would be on subsequent clicks. 3. Rename the static map variable to better fit our coding style and be more understandable. --- src/kits/tracker/ContainerWindow.cpp | 64 +++++++++++++++------------- src/kits/tracker/Model.cpp | 2 + src/kits/tracker/PoseView.cpp | 10 ++--- 3 files changed, 41 insertions(+), 35 deletions(-) diff --git a/src/kits/tracker/ContainerWindow.cpp b/src/kits/tracker/ContainerWindow.cpp index b48b683e77..e5b044bc8d 100644 --- a/src/kits/tracker/ContainerWindow.cpp +++ b/src/kits/tracker/ContainerWindow.cpp @@ -130,6 +130,7 @@ class DraggableContainerIcon : public BView { struct AddOneAddonParams { BObjectList *primaryList; BObjectList *secondaryList; + BObjectList *mimeTypes; }; struct StaggerOneParams { @@ -2838,34 +2839,12 @@ BContainerWindow::EachAddon(BPath &path, bool (*eachAddon)(const Model *, BDirectory dir; BEntry entry; + + BObjectList *mimeTypes = ((AddOneAddonParams *)params)->mimeTypes; if (dir.SetTo(path.Path()) != B_OK) return false; - // build a list of the MIME types of the selected items - - BObjectList mimeTypes(10, true); - - int32 count = PoseView()->SelectionList()->CountItems(); - if (!count) { - // just add the type of the current directory - AddMimeTypeString(mimeTypes, TargetModel()); - } else { - for (int32 index = 0; index < count; index++) { - BPose *pose = PoseView()->SelectionList()->ItemAt(index); - AddMimeTypeString(mimeTypes, pose->TargetModel()); - // If it's a symlink, resolves it and add the Target's MimeType - if (pose->TargetModel()->IsSymLink()) { - Model* resolved = new Model( - pose->TargetModel()->EntryRef(), true, true); - if (resolved->InitCheck() == B_OK) { - AddMimeTypeString(mimeTypes, resolved); - } - delete resolved; - } - } - } - dir.Rewind(); while (dir.GetNextEntry(&entry) == B_OK) { Model *model = new Model(&entry); @@ -2887,7 +2866,7 @@ BContainerWindow::EachAddon(BPath &path, bool (*eachAddon)(const Model *, bool primary = false; - if (mimeTypes.CountItems()) { + if (mimeTypes->CountItems()) { BFile file(&entry, B_READ_ONLY); if (file.InitCheck() == B_OK) { BAppFileInfo info(&file); @@ -2905,8 +2884,8 @@ BContainerWindow::EachAddon(BPath &path, bool (*eachAddon)(const Model *, // check all supported types if it has some set if (!secondary) { - for (int32 i = mimeTypes.CountItems(); !primary && i-- > 0;) { - BString *type = mimeTypes.ItemAt(i); + for (int32 i = mimeTypes->CountItems(); !primary && i-- > 0;) { + BString *type = mimeTypes->ItemAt(i); if (info.IsSupportedType(type->String())) { BMimeType mimeType(type->String()); if (info.Supports(&mimeType)) @@ -2970,8 +2949,6 @@ BContainerWindow::BuildAddOnMenu(BMenu *menu) break; delete item; } - - _UpdateSelectionMIMEInfo(); BObjectList primaryList; BObjectList secondaryList; @@ -2980,12 +2957,39 @@ BContainerWindow::BuildAddOnMenu(BMenu *menu) params.primaryList = &primaryList; params.secondaryList = &secondaryList; + // build a list of the MIME types of the selected items + BObjectList mimeTypes(10, true); + + int32 count = PoseView()->SelectionList()->CountItems(); + if (!count) { + // just add the type of the current directory + AddMimeTypeString(mimeTypes, TargetModel()); + } else { + _UpdateSelectionMIMEInfo(); + for (int32 index = 0; index < count; index++) { + BPose *pose = PoseView()->SelectionList()->ItemAt(index); + + AddMimeTypeString(mimeTypes, pose->TargetModel()); + // If it's a symlink, resolves it and add the Target's MimeType + if (pose->TargetModel()->IsSymLink()) { + Model* resolved = new Model( + pose->TargetModel()->EntryRef(), true, true); + if (resolved->InitCheck() == B_OK) { + AddMimeTypeString(mimeTypes, resolved); + } + delete resolved; + } + } + } + + params.mimeTypes = &mimeTypes; + EachAddon(AddOneAddon, ¶ms); primaryList.SortItems(CompareLabels); secondaryList.SortItems(CompareLabels); - int32 count = primaryList.CountItems(); + count = primaryList.CountItems(); for (int32 index = 0; index < count; index++) menu->AddItem(primaryList.ItemAt(index)); diff --git a/src/kits/tracker/Model.cpp b/src/kits/tracker/Model.cpp index 7f5ea56b7f..dcf5e3e889 100644 --- a/src/kits/tracker/Model.cpp +++ b/src/kits/tracker/Model.cpp @@ -883,6 +883,8 @@ Model::AttrChanged(const char *attrName) if (!attrName || strcmp(attrName, kAttrMIMEType) == 0 || strcmp(attrName, kAttrPreferredApp) == 0) { + ModelNodeLazyOpener opener(this); + opener.OpenNode(); char mimeString[B_MIME_TYPE_LENGTH]; BNodeInfo info(fNode); if (info.GetType(mimeString) != B_OK) diff --git a/src/kits/tracker/PoseView.cpp b/src/kits/tracker/PoseView.cpp index 592c04b0d0..fba21fe3db 100644 --- a/src/kits/tracker/PoseView.cpp +++ b/src/kits/tracker/PoseView.cpp @@ -155,7 +155,7 @@ struct attr_column_relation { }; -static struct attr_column_relation attributes[] = { +static struct attr_column_relation sAttrColumnMap[] = { { AttrHashString(kAttrStatModified, B_TIME_TYPE), B_STAT_MODIFICATION_TIME }, { AttrHashString(kAttrStatSize, B_OFF_T_TYPE), @@ -5466,11 +5466,11 @@ BPoseView::AttributeChanged(const BMessage *message) if (message->FindInt32("fields", &fields) != B_OK) return true; - for (int32 i = sizeof(attributes) / sizeof(attr_column_relation); + for (int i = sizeof(sAttrColumnMap) / sizeof(attr_column_relation); i--;) { - if (attributes[i].attrHash == PrimarySort() - || attributes[i].attrHash == SecondarySort()) { - if ((fields & attributes[i].fieldMask) != 0) { + if (sAttrColumnMap[i].attrHash == PrimarySort() + || sAttrColumnMap[i].attrHash == SecondarySort()) { + if ((fields & sAttrColumnMap[i].fieldMask) != 0) { _CheckPoseSortOrder(fPoseList, pose, poseListIndex); if (fFiltering && visible) _CheckPoseSortOrder(fFilteredPoseList, pose, index);